C++ Programming (operator overloading)

Operator overloading is a method of allowing existing operators to be overloaded so that when these operators are used with class objects, the operators have meaning appropriate to the new types.

Example:

class NumberClass{
public:
//Overloading assignment operator
const NumberClass& operator=(const NumberClass &);
private:
int a;
int b;
int c;
};

const NumberClass& NumberClass::operator=(const NumberClass& source)
{
a = source.a;
b = source.b;
c = source.c;
return *this;
}

main()
{
NumberClass A(1,1,1), B(2,2,2);
A=B; // Invoked the overloaded assignment function
return 0;
}