List of operators that cannot be overloaded.
Increment the time using ++
Decrement the time using ++
Add two object using “+” operator with friend function
class distance (feet,inches) with “+” operator
class distance (feet,inches) with “+” operator with friend function
class distance (km,m) with “+” operator
class distance (km,m) with “+” operator with friend function
class distance (m,cm) with “+” operator
class distance (m,cm) with “+” operator with friend function
class distance (km,m,cm) with “+” operator
class distance (km,m,cm) with “+” operator with friend function
class distance (km,m,cm,mm) with “+” operator
class distance (km,m,cm,mm) with “+” operator with friend function
class time(hh,mm,ss) with “+” operator
class time(hh,mm,ss) with “+” operator with friend function
class complex(real,ing) with “+” operator
class complex(real,ing) with “+” operator with friend function
class string(str) with “+” operator
class string(str) with “+” operator with friend function

Example:13
Declare a class named “distance” with attributes as m and cm. Take input for two objects calculate and print their sum using overloaded binary operator “+” with friend function.

code

Output:

Example:14
Declare a class named “distance” with attributes as km, m and cm. Take input for two objects calculate and print their sum using overloaded binary operator “+”.

code

Output:

Example:15
Declare a class named “distance” with attributes as km, m and cm. Take input for two objects calculate and print their sum using overloaded binary operator “+” with friend function.

code

Output:

Important Pages