C++ Operator Overloading Question:
Download Questions PDF

The output of this program?

#include <iostream>
using namespace std;
ostream & operator<<(ostream & i, int n)
{
return i;
}
int main()
{
cout << 5 << endl;
cin.get();
return 0;
}
a) 5
b) 6
c) error
d) runtime error

C++ Operator Overloading Interview Question
C++ Operator Overloading Interview Question

Answer:

c) error

Download C++ Operator Overloading Interview Questions And Answers PDF

Previous QuestionNext Question
Output of this program?

#include <iostream>
using namespace std;
class myclass
{
public:
int i;
myclass *operator->()
{return this;}
};
int main()
{
myclass ob;
ob->i = 10;
cout << ob.i << " " << ob->i;
return 0;
}
a) 10 10
b) 11 11
c) error
d) runtime error
Operator overloading is:
a) making c++ operator works with objects
b) giving new meaning to existing operator
c) making new operator
d) both a & b