Skip to main content

Operators that cannot be overloaded

Short answer

Operators that cannot be overloaded are :: (scope resolution), . (member access), .* (pointer-to-member), ?: (ternary), sizeof, and typeid. These operate on names or types, not values, and overloading would compromise language safety.

What are the non-overloadable operators in C++?

Most C++ operators can be overloaded, but the following cannot be overloaded:

OperatorName
::Scope resolution operator
.Member access (dot) operator
.*Pointer-to-member operator
?:Conditional (ternary) operator
sizeofSize-of operator
typeidRun-time type information operator

The cast operators const_cast, dynamic_cast, static_cast and reinterpret_cast, and the preprocessor symbols # and ##, also cannot be overloaded.

Reason: these operators work on names or types (not values), or their meaning is fixed by the language, so changing them could make the language unsafe or ambiguous. Also, the precedence, associativity and number of operands of an operator cannot be changed by overloading, and new operator symbols cannot be created.

Note: =, [], () and -> can be overloaded, but only as member functions.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Object Oriented Programming chapter 5 questions →