The functions of most built-in operators can be redefined in C++. These operators can be redefined or ‘overloaded’ globally or in a class by class basis. Overloaded operators are implemented as functions and can be class-member or global functions.

The name of an overloaded operator is operatorx, where x is the operator. For example, to overload the addition operator, you define a function called operator+. Similarly, to overload the addition/assignment operator, +=, define a function called operator+=.

Although these operators are usually called implicitly by the compiler when they are encountered in code, they can be invoked explicitly the same way as any member or nonmember function is called.

About our authors: Team EQA

You have viewed 1 page out of 62. Your C++ learning is 0.00% complete. Login to check your learning progress.

#