Inheritance hierarchies support flexibile implementation by allowing substitution, in a method's calling arguments,
of a base reference by a reference to an instance of any derived type. See results of substitution, below.
Demonstrating inheritance
===========================
The night before inspection:
Wang is sleeping
Gonsales is sleeping
Sam is sleeping
George is sleeping
Slacker is sleeping
The morning of inspection:
Wang is eating
Gonsales is eating
Sam is eating
George is eating
Slacker is eating
The inspection:
Captain Wang is inspecting his platoon
casual salute
Sergeant Gonsales presents his platoon
brisk salute
Sam presents his equipment for inspection:
snappy salute
Sam presents M16 rifle
Sam presents Field Pack
George presents his equipment for inspection:
snappy salute
George presents 50 Caliber Machinegun
George presents Field Pack
Slacker presents his equipment for inspection:
snappy salute
Sorry sir, I forgot my equipment
Press any key to continue . . .