Subscript and Function Call Operators

These two operators are binary operators, but they are quite different from other C++ overloaded binary operators in how the client call to the operator is converted to a binary expression. For other overloaded operators, the target of the message is used as the left operand in the expression, with the operator (from the method name) inserted between the right and the left operand and the parameter of the function call used as the right operand of the expression. This is not so with the subscript and function call operators. (You will see the examples soon.)

Another difference is that these overloaded operators can be implemented as class members only—they cannot be implemented as global nonmember functions. ...

Get Core C++ A Software Engineering Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.