How to overload pointer or class member access -> and comma , operators in C++?

Overload ->

Pointer or class member access operator -> is a unary operator.

Syntax of overloading ->


where, element is a member within object.

Overload ,

Comma , is a binary operator. When comma operator is overloaded only the rightmost values of operands are retained and rest all the values are discarded.

Syntax of overloading ,

type class_name::operator, (type operand)


. . .


Leave a Reply