Operator overloading: Overloading a unary operator is similar to overloading a binary operator...

13
Operator overloading: Overloading a unary operator is similar to overloading a binary operator except that there is one Operand to deal with. When you overload a unary operator using a member function, the function has no parameters. Since, there is only one operand, it is this operand that generates the call to the operator function. There is no need for another parameter. /* Program of Unary operator*/ #include<iostream.h> #include<conio.h> class complex { int a,b,c; public:

Transcript of Operator overloading: Overloading a unary operator is similar to overloading a binary operator...

Slide 1

Operator overloading: Overloading a unary operator issimilar to overloading a binary operator except that there is oneOperand to deal with. When you overload a unary operator usinga member function, the function has no parameters. Since, thereis only one operand, it is this operand that generates the call tothe operator function. There is no need for another parameter.

/* Program of Unary operator*/

#include#includeclass complex{ int a,b,c; public: complex(){}

void getvalue() { cout