Make abstract base class Shape
- Pure virtual functions (must be implemented)
- getName, print
- Default implementation does not make sense
- Virtual functions (may be redefined)
- getArea, getVolume; initially return 0.0
- If not redefined, uses base class definition
- Derive classes Point, Circle, Cylinder
Figure 1:
Defining the polymorphic interface for the Shape hierarchy classes.
|
Figure 2:
Abstract base class Shape header file and Abstract base class Shape.
|
Figure 3:
Point class header file.
|
Figure 4:
Point class implementation file. (part 1 of 2)
|
Figure 5:
Point class implementation file. (part 2 of 2)
|
Figure 6:
Circle class header file and Circle class that inherits from
class Point. (part 1 of 2)
|
Figure 7:
Circle class that inherits from class Point. (part 2 of 2)
|
Figure 8:
Cylinder class header file.
|
Figure 9:
Cylinder class implementation file. (part 1 of 2)
|
Figure 10:
Cylinder class implementation file. (part 2 of 2)
|
Figure 11:
Demonstarting polymorphism via a hierarchy headed by an abstract base class. (part 1 of 3)
|
Figure 12:
Demonstarting polymorphism via a hierarchy headed by an abstract base class. (part 2 of 3)
|
Figure 13:
Demonstarting polymorphism via a hierarchy headed by an abstract base class. (part 3 of 3)
|
2004-07-29