Professional Documents
Culture Documents
In above program, + operator is adding two primitive data types. Objects are non-primitive data
types. In C++, we can redefine the way operators work on non-primitive data types. If you see
commented portion, compiler don’t know how to add these two values because these are objects of
user-defined data types. As it can add 3+4+1+5 or 3+4 and 1+5 or 3+1 and 4+5 or any other
combination. So we can overload the operator for user-defined data types.
Example
We have seen binary operator overloading. Operator that performs operation on two parameters.
Example