August 2012
Intermediate to advanced
976 pages
30h 17m
English
The fact that a class is a scope explains why we must provide the class name as well as the function name when we define a member function outside its class (§ 7.1.2, p. 259). Outside of the class, the names of the members are hidden.
Once the class name is seen, the remainder of the definition—including the parameter list and the function body—is in the scope of the class. As a result, we can refer to other class members without qualification.
For example, recall the clear member of class Window_mgr (§ 7.3.4, p. 280). That function’s parameter uses a type that is defined by Window_mgr:
void Window_mgr::clear(ScreenIndex i){ Screen &s = screens[i]; s.contents = string(s.height * s.width, ' '); ...
Read now
Unlock full access