from : http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B


Arithmetic operators

Operator nameSyntaxOverloadableIncluded
in C
Prototype examples (T is any type)
As member of TOutside class definitions
Basic assignment= bYesYesT& T::operator =(const T& b);N/A
Addition+ bYesYesT T::operator +(const T& b) const;T operator +(const T& a, const T& b);
Subtraction- bYesYesT T::operator -(const T& b) const;T operator -(const T& a, const T& b);
Unary plus (integer promotion)+aYesYesT T::operator +() const;T operator +(const T& a);
Unary minus (additive inverse)-aYesYesT T::operator -() const;T operator -(const T& a);
Multiplication* bYesYesT T::operator *(const T& b) const;T operator *(const T &a, const T& b);
Division/ bYesYesT T::operator /(const T& b) const;T operator /(const T& a, const T& b);
Modulo (remainder)% bYesYesT T::operator %(const T& b) const;T operator %(const T& a, const T& b);
IncrementPrefix++aYesYesT& T::operator ++();T& operator ++(T& a);
Suffixa++YesYesT T::operator ++(int);T operator ++(T& a, int);
Note: C++ uses the unnamed dummy-parameter int to differentiate between prefix and suffix increment operators.
DecrementPrefix--aYesYesT& T::operator --();T& operator --(T& a);
Suffixa--YesYesT T::operator --(int);T operator --(T& a, int);
Note: C++ uses the unnamed dummy-parameter int to differentiate between prefix and suffix decrement operators.

[edit]Comparison operators/relational operators

Operator nameSyntaxOverloadableIncluded
in C
Prototype examples (T is any type)
As member of TOutside class definitions
Equal to== bYesYesbool T::operator ==(const T& b) const;bool operator ==(const T& a, const T& b);
Not equal to!= bYesYesbool T::operator !=(const T& b) const;bool operator !=(const T& a, const T& b);
Greater than> bYesYesbool T::operator >(const T& b) const;bool operator >(const T& a, const T& b);
Less than< bYesYesbool T::operator <(const T& b) const;bool operator <(const T& a, const T& b);
Greater than or equal to>= bYesYesbool T::operator >=(const T& b) const;bool operator >=(const T& a, const T& b);
Less than or equal to<= bYesYesbool T::operator <=(const T& b) const;bool operator <=(const T& a, const T& b);

[edit]Logical operators

Operator nameSyntaxOverloadableIncluded
in C
Prototype examples (T is any type)
As member of TOutside class definitions
Logical negation (NOT)!aYesYesbool T::operator !() const;bool operator !(const T& a);
Logical AND&& bYesYesbool T::operator &&(const T& b) const;bool operator &&(const T& a, const T& b);
Logical OR|| bYesYesbool T::operator ||(const T& b) const;bool operator ||(const T& a, const T& b);

[edit]Bitwise operators

Operator nameSyntaxOverloadableIncluded
in C
Prototype examples (T is any type)
As member of TOutside class definitions
Bitwise NOT~aYesYesT T::operator ~() const;T operator ~(const T& a);
Bitwise AND& bYesYesT T::operator &(const T& b) const;T operator &(const T& a, const T& b);
Bitwise OR| bYesYesT T::operator |(const T& b) const;T operator |(const T& a, const T& b);
Bitwise XOR^ bYesYesT T::operator ^(const T& b) const;T operator ^(const T& a, const T& b);
Bitwise left shift[note 1]<< bYesYesT T::operator <<(const T& b) const;T operator <<(const T& a, const T& b);
Bitwise right shift[note 1][note 2]>> bYesYesT T::operator >>(const T& b) const;T operator >>(const T& a, const T& b);

[edit]Compound assignment operators

Operator nameSyntaxMeaningOverloadableIncluded
in C
Prototype examples (T is any type)
As member of TOutside class definitions
Addition assignment+= b= a + bYesYesT& T::operator +=(const T& b);T& operator +=(T& a, const T& b);
Subtraction assignment-= b= a - bYesYesT& T::operator -=(const T& b);T& operator -=(T& a, const T& b);
Multiplication assignment*= b= a * bYesYesT& T::operator *=(const T& b);T& operator *=(T& a, const T& b);
Division assignment/= b= a / bYesYesT& T::operator /=(const T& b);T& operator /=(T& a, const T& b);
Modulo assignment%= b= a % bYesYesT& T::operator %=(const T& b);T& operator %=(T& a, const T& b);
Bitwise AND assignment&= b= a & bYesYesT& T::operator &=(const T& b);T& operator &=(T& a, const T& b);
Bitwise OR assignment|= b= a | bYesYesT& T::operator |=(const T& b);T& operator |=(T& a, const T& b);
Bitwise XOR assignment^= b= a ^ bYesYesT& T::operator ^=(const T& b);T& operator ^=(T& a, const T& b);
Bitwise left shift assignment<<= b= a << bYesYesT& T::operator <<=(const T& b);T& operator <<=(T& a, const T& b);
Bitwise right shift assignment[note 2]>>= b= a >> bYesYesT& T::operator >>=(const T& b);T& operator >>=(T& a, const T& b);

[edit]Member and pointer operators

Operator nameSyntaxOverloadableIncluded
in C
Prototype examples (T, T2 and R are any type)
As member of TOutside class definitions
Array subscripta[b]YesYesR& T::operator [](const T2& b);
N/A
Indirection ("object pointed to by a")*aYesYesR& T::operator *();R& operator *(T& a);
Reference ("address of a")&aYesYesT* T::operator &();T* operator &(T& a);
Structure dereference ("member b of object pointed to by a")a->bYesYesR* T::operator ->();
N/A
Structure reference ("member b of object a")a.bNoYesN/A
Member pointed to by b of object pointed to by a[note 3]a->*bYesNoR T::operator->*(R);[note 4]R operator->*(T, R);[note 4]
Member pointed to by b of object aa.*bNoNoN/A

[edit]Other operators

Operator nameSyntaxOverloadableIncluded
in C
Prototype examples (T, R, Arg1 and Arg2 are any type)
As member of TOutside class definitions
Function call
See Function object.
a(a1, a2)YesYesR T::operator ()(Arg1 a1, Arg2 a2, …);N/A
Commaa, bYesYesR& T::operator ,(R& b) const;R& operator ,(const T& a, R& b);
Ternary conditional? b : cNoYesN/A
Scope resolutiona::bNoNoN/A
Size-ofsizeof(a)[note 5]
sizeof(type)
NoYesN/A
Align-ofalignof(type)
or_Alignof(type)[note 6]
NoNoN/A
Type identificationtypeid(a)
typeid(type)
NoNoN/A
Cast(type) aYesYesT::operator R() const;N/A
Note: for user-defined conversions, the return type implicitly and necessarily matches the operator name.
Allocate storagenew typeYesNovoid* T::operator new(size_t x);void* operator new(size_t x);
Allocate storage (array)new type[n]YesNovoid* T::operator new[](size_t x);void* operator new[](size_t x);
Deallocate storagedelete aYesNovoid T::operator delete(void* x);void operator delete(void* x);
Deallocate storage (array)delete[] aYesNovoid T::operator delete[](void* x);void operator delete[](void* x);