Question 1
Question 2
1) Comparison Operator ( == ) 2) Assignment Operator ( = )
Question 3
Question 4
Which of the following is an example of compile-time polymorphism?
Function Overloading
Virtual function
Function Overriding
Dynamic Casting
Question 5
#include<iostream>
using namespace std;
class Point {
private:
int x, y;
public:
Point() : x(0), y(0) { }
Point& operator()(int dx, int dy);
void show() {cout << "x = " << x << ", y = " << y; }
};
Point& Point::operator()(int dx, int dy)
{
x = dx;
y = dy;
return *this;
}
int main()
{
Point pt;
pt(3, 2);
pt.show();
return 0;
}
Question 6
#include <iostream>
using namespace std;
class Test2
{
int y;
};
class Test
{
int x;
Test2 t2;
public:
operator Test2 () { return t2; }
operator int () { return x; }
};
void fun ( int x) { cout << "fun(int) called"; }
void fun ( Test2 t ) { cout << "fun(Test 2) called"; }
int main()
{
Test t;
fun(t);
return 0;
}
Question 7
Which of the following operators cannot be overloaded?
Question 8
Which of the following statements are true regarding C++?
(a) Overloading gives the capability to an existing operator to operate on other data types.
(b) Inheritance in object oriented programming provides support to reusability.
(c) When object of a derived class is defined, first the constructor of derived class is executed then constructor of a base class is executed.
(d) Overloading is a type of polymorphism.
Choose the correct option from those given below:
(a) and (b) only
(a), (b) and (c) only
(a), (b) and (d) only
(b), (c) and (d) only
Question 9
What is Operator overloading?
There are 9 questions to complete.