Class Point3 (Figs. 1-2) declares data members x and y as private and exposes member functions setX, getX, setY, getY and print for manipulating these values.
Figure 1:
Point3 class header file. Point/Circle Hierarchy Using private Data
|
Figure 2:
Point3 class uses member functions to manipulate its private data.
|
Figure 3:
Circle4 class header file.
|
Figure 4:
Circle4 class that inherits from class Point3, which does not provide protected data. (part 1 of 2)
|
Figure 5:
Circle4 class that inherits from class Point3, which does not provide protected data. (part 2 of 2)
|
Figure 6:
Base class private data is accessible to a derived class via public or protected member function inherited by the derived class.
|
2004-07-22