Nov 10 2013

C++ Operator Functions Declaration

Published by at 11:08 pm under C Programming

A summary on how the different operator functions, in C++,  have to be declared

(replace @ by the operator in each case):

Expression Operator Member function Global function
@a        + – * & ! ~ ++ — A::operator@() operator@(A)
a@        ++ — A::operator@(int) operator@(A,int)
a@b        + – * / % ^ & | < > == !=

<= >= << >> && || ,

A::operator@ (B) operator@(A,B)
a@b        = += -= *= /= %= ^= &=

|= <<= >>= []

A::operator@ (B)          –
a(b, c…)        () A::operator() (B, C…)          –
a->x        -> A::operator->()          –

PS: This is for my reference that I copied from cplusplus.com.

Comments Off on C++ Operator Functions Declaration

Comments are closed at this time.