Computer Science, asked by omtiwari6436, 6 months ago

In case of binary operator overloading with member function, which of following statement should be taken into consideration?

A. Right hand operand must be object.
B. Left hand operand must be object
C. Both the operands must be objects.
D. none of the above
Selery​

Answers

Answered by sumukhdpai
0

Answer:

B. Left hand operand must be object

Answered by ankhidassarma9
0

Answer:

In case of binary operator overloading with member function, both the operands must be objects.

Explanation:

In C++, we can change the way binary operators work for user-defined types like objects and structures. This is known as binary operator overloading.

For example,

  • Suppose we have created three objects obj1, obj2 and obj3 from a class named Complex that represents complex numbers.
  • Since operator overloading allows us to change how operators work, we can redefine how the + operator works and use it to add the complex numbers of obj1 and obj2 by writing new code.
  • When we overload the binary operator for user-defined types by using the code: obj3 = obj1 + obj2; The operator function is called using the obj1 object and obj2 is passed as an argument to the user defined function.
Similar questions