Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: All
Sep 4, 1998

Restrictions on Operator Overloading

The following restrictions apply to operator overloading:

1. Invention of new operators is not allowed. For example:

void operator @ (int) ; //illegal, @ is not a built-in operator or a type name
2. Neither the precedence nor the number of arguments of an operator may be altered. An overloaded && for example, must have exactly two arguments--just like the built-in && operator.

3. The following operators cannot be overloaded:

Direct member access operator 				. 
De-reference pointer to class member operator 		.*
Scope resolution operator				::
Conditional operator					?:
Sizeof operator						sizeof
Similarly, any of the new casting operators: static_cast<>, dynamic_cast<>, reinterpret_cast<> and const_cast<>, as well as the # and ## preprocessor tokens, may not be overloaded.
Danny Kalev
Thanks for your registration, follow us on our social networks to keep up-to-date