Polymorphism Examples
Short example of Polymorphism
Square Circle
output
Long Example of useful Polymorphism from Gaddis book: Graded Activity Code from Chapter 15.
- Parent - GradedActivity
- header - getLetterGrade
- CPP
- Child - PassFailActivity
- header - getLetterGrade
- CPP
- GrandChild - PassFailExam
- header
- CPP
- MainV1 - Program 15-11 - Get Letter Grade for test now gives a "P"
- CPP
- MainV2 - Program 15-12 - GradedActivity and PassFailExam passed to displayGrade
- CPP
- MainV3 - Program 15-13 - activity (in displayGrade) is Pass by Value so polymorphism not possible
- CPP
- MainV4 - Program 15-14 - Base Class Pointer. array test contains different types
- CPP
Polymorphism with vectors
PolyVector.cpp
PolyVector output
Polymorphism
with Abstract base class
empmain2.cpp
employ2.cpp
employ2.h
hourly2.cpp
hourly2.h
output