Skip to main content

Overloadable operators in C++

Short answer

Most operators can be overloaded: arithmetic (+, -, *, /, %), unary (++, --, !, -), relational (==, <, >, <=, >=, !=), logical (&&, ||, !), bitwise (&, |, ^, ~, <<, >>), assignment (=, +=, etc.), subscript ([]), function call (()), member access (->, ->*), comma, address-of, and memory (new, delete). Not overloadable: :: . .* ?: sizeof typeid.

What are the overloadable operators in C++?

C++ allows most of its operators to be overloaded for user-defined types.

CategoryOperators
Arithmetic+ - * / %
Unary+ - ++ -- ! ~
Relational== != < > <= >=
Logical&& || !
Bitwise& | ^ ~ << >>
Assignment= += -= *= /= %= &= |= ^= <<= >>=
Subscript, call, pointer[] () -> ->*
Address, comma& ,
Memorynew delete new[] delete[]

Notes:

  • =, [], () and -> must be overloaded as member functions.
  • Operators like << and >> for streams are overloaded as non-member (friend) functions.
  • Operators :: . .* ?: sizeof typeid cannot be overloaded.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Object Oriented Programming chapter 5 questions →