Share via


Class-Member Access

Class-member access can be controlled by overloading the member-selection operator (–>). This operator is considered a unary operator in this usage, and the overloaded operator function must be a class member function. Therefore, the declaration for such a function is:

class-type *operator–>()

where class-type is the name of the class to which this operator belongs. The member-selection operator function must be a nonstatic member function.

This operator is used (often in conjunction with the pointer-dereference operator) to implement “smart pointers” that validate pointers prior to dereference or count usage.

The . member-selector operator cannot be overloaded.