A name declared within a member function hides a declaration of the same name whose scope extends to or past the end of the member function's class.

When the scope of a declaration extends to or past the end of a class definition, the regions defined by the member definitions of that class are included in the scope of the class. Members defined lexically outside of the class are also in this scope. In addition, the scope of the declaration includes any portion of the declarator following the identifier in the member definitions.

The name of a class member has class scope and can only be used in the following cases:

In a member function of that class
In a member function of a class derived from that class
After the . (dot) operator applied to an instance of that class
After the . (dot) operator applied to an instance of a class derived from that class, as long as the derived class does not hide the name
After the -> (arrow) operator applied to a pointer to an instance of that class
After the -> (arrow) operator applied to a pointer to an instance of a class derived from that class, as long as the derived class does not hide the name
After the :: (scope resolution) operator applied to the name of a class
After the :: (scope resolution) operator applied to a class derived from that class.




Designed By Blogger Templates | Templatelib & Distributed By Blogspot Templates