Syntax of operator overloading and limitations in C++

Operators are overloaded by creating operator functions which can be either members or non members of a class. Operator keyword is used to create operator functions.

Syntax of member operator function:

return_type class_name::operator#(arguments_list)



Here # is a placeholder.

Limitations of operator overloading:

1) Precedence of an operator can’t be altered.

2) Number of operands that operator takes can’t be changed.

3) Operator function can’t have default arguments.

4) Following operators can’t be overloaded- . : : .* ?

Leave a Reply