Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) operator

 

Keyword to overload an operator. An operator performs a function or member function.

 

 

 

 

 

Overview of operators (incomplete)

 

operator name operator
.*
->*
address-of operator &
dereference operator *
assign operator =
bit shift left assign operator <<=
bit shift right assign operator >>=
bitwise and operator &
bitwise not operator ~
bitwise or operator |
bitwise xor operator ^
bitwise xor assign operator

^=
comma operator ,
decrement operator --
divide assign operator /=
divide operator /
equal operator ==
function call operator ()
greater than operator >
greater than or equal operator >=
increment operator ++
index operator [
index operator []
index operator ]
less than operator <
less than or equal operator <=
logical and operator &&
logical not operator !
||, logical or operator ||
member access operator .
arrow operator ->
minus assign operator -=
minus operator -
modulus assign operator %=
modulus operator %
multiply assign operator *=
multiply operator *
not equal operator !=
plus assign operator +=
plus operator +
questionmark colon operator ?:
scope operator ::
sizeof operator sizeof

stream out operator <<

 

 

 

 

 

Advice

 

 

 

 

 

 

References

 

  1. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 17.7. Advice, page 547: '[1] Define operators primarily to mimic conventional usage'
  2. Paul Deitel, Harvey Deitel. C++11 for programmers (2nd edition). 2014. ISBN: 978-0-13-343985-4. Chapter 2.4, Good Programming Practice 2.7. page 28: 'Place spaces on either side of a binary operator. This will make the operator stand out and make the program more readable.'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict