Names used with the binary scope-resolution operator (::) are called “qualified names.” The name specified after the binary scope-resolution operator must be a member of the class specified on the left of the operator or a member of its base class(es).
Names specified after the member-selection operator (. or –>) must be members of the class type of the object specified on the left of the operator or members of its base class(es). Names specified on the right of the member-selection operator (–>) can also be objects of another class type, provided that the left-hand side of –> is a class object and that the class defines an overloaded member-selection operator (–>) that evaluates to a pointer to some other class type. (This provision is discussed in more detail in Class Member Access in Chapter 12.)
The compiler searches for names in the following order, stopping when the name is found:
However, you can make modifications to this search order as follows:
If the name refers to a nonstatic member but is used in a static member function, an error message is generated. Similarly, if the name refers to any nonstatic member in an enclosing class, an error message is generated because enclosed classes do not have enclosing-class this pointers.