Next:
Separating Interface from Implementation
Up:
Introduction, Classes and Data
Previous:
Implementing a Time Abstract
Contents
Class Scope and Accessing Class Members
Class scope
Data members, member functions
Within class scope
Class members; Immediately accessible by all member functions, Referenced by name
Outside class scope
Referenced through handles; Object name, reference to object, pointer to object
File scope
Nonmember functions
Function scope
Variables declared in member function
Only known to function
Variables with same name as class-scope variables
Class-scope variable
hidden
; Access with scope resolution operator (
::
)
ClassName::classVariableName
Variables only known to function they are defined in
Variables are destroyed after function completion
Operators to access class members
Identical to those for
struct
s
Dot member selection operator (
.
)
Object
Reference to object
Arrow member selection operator (
)
pointers
Figure 1.7:
Demonstrating the class member access operators
and
Next:
Separating Interface from Implementation
Up:
Introduction, Classes and Data
Previous:
Implementing a Time Abstract
Contents
2004-07-29