C++ Operator Overloading


To use and operator on class objects, the operator must be overloaded for the class - with tow exceptions: C++ is an operator rich language. The following operators can be overloaded:

+-*/%^&|~!=
<>+=-=*=/=%=^=&=|=<<
>>>>=<<===!=<=>=&&||++--
->*,-<[]()newdelete

The following operators cannot be overloaded:

..*::?:sizeof


The following general rules apply when overloading an operator in C++: