Using friend operator function, following perfect set of operators may not be overloaded.
(a) = , ( ) , [ ] , ->
(b) <<, = = , [ ] , >>
(c) ?, = , ( ) , ++
(d) None of these

(a) You cannot overload = , ( ) , [ ] , -> operator using friend function. Most of the operator you can overload such as unary, binary operator etc

An operator function is created using _____________ keyword.
(a) iterator
(b) allocator
(c) constructor
(d) operator

(d) An operator function is created using operator keyword.
General form of a member operator function is as follows.
ret-type class-name::operator operator Sign (arg-list)
// operations


While overloading binary operators using member function, it requires ___ arguments.

(a) Zero
(b) One
(c) Two
(d) Three

(b) If overloaded as a member function, binary operators require one argument. The argument
contains value of the object, which is to the right of the operator.


In case of operator overloading, operator function must be ______ .

1. Static member functions
2. Non- static member functions
3. Friend Functions
(a) Only 2
(b) Only 1, 3
(c) Only 2 , 3
(d) All 1 , 2, 3

(c) No other operators are overloaded


When overloading unary operators using Friend function, it requires_____ argument/s.

(a) Zero
(b) One
(c) Two
(d) None of these.

(b) The friend functions are more useful in operator overloading. They offer better flexibility, which is not provided by the member function of the class. The difference between member function and friend function is that the member function takes argument ex-plicitly.On the contrary, the friend function needs the parameters to be explicitly passed.


Which of the following operators cannot be overloaded.

(a) . (Member Access or Dot operator)
(b) ?: (Ternary or Conditional Operator
(c):: (Scope Resolution Operator)
(d) All of the above

(d) There is no need for explanation


Which of the following operators should be preferred to overload as a global function rather than a member method?

(a) Postfix ++
(b) Comparison Operator
(c) Insertion Operator <<
(d) Prefix++

(c) cout is an object of ostream class which is a compiler defined class.When we do “cout << obj” where obj is an object of our class, the compiler first looks for an operator function in ostream, then it looks for a global function. One way to overload insertion operator is to modify ostream class which may not be a good idea. So we make a global method.


Find the output of the Following:

using namespace std;

class Point {
int x, y;
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);
return 0;

(a) x = 3, y = 2
(b) Compiler Error
(c) x = 2, y = 3
(d) None of these.

(a) Note that the class B has as conversion operator overloaded, so an object of B can be converted to that of (A) Also, class A has a constructor which can be called with single integer argument, so an int can be converted to (A)


How C++ compiler does differ between overloaded postfix and prefix operators?

(a) C++ doesn’t allow both operators to be overloaded in a class
(b) A postfix ++ has a dummy parameter
(c) A prefix ++ has a dummy parameter
(d) By making prefix ++ as a global function and postfix as a member function.

(b) The pre- and post-increment are two distinct operators, and require separate overloads. C++ doesn’t allow overloading solely on return type, so having different return types as in your example wouldn’t be sufficient to disambiguate the two methods. The dummy argument is the mechanism that the designer of C++ chose for the disambiguation.


How can we restrict dynamic allocation of objects of a class using new?

(a) By overloading new operator
(b) By making an empty private new operator.
(c) By making an empty private new and new[] operators
(d) By overloading new operator and new[] operators

(c) If we declare new and [] new operators, then the objects cannot be created anywhere (within the class and outside the class)
Operator Overloading