O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Referring to an Object as Its Class or Its Superclass

A look at the new main.cpp in Listing 22.3 shows that a reference to a superclass can refer to a descendant class as a result of inheritance.

Listing 22.3. main.cpp Using the New Classes
 *1: #include "PersistentTapeExternalInterfaceModule.h" 2: #include "AccumulatorModule.h" *3: #include "PersistentTapeModule.h" 4: #include "ControllerModule.h" 5: 6: int main(int argc, char* argv[]) 7: { *8: SAMSCalculator::aPersistentTapeExternalInterface ExternalInterface(argv[1]); 9: SAMSCalculator::anAccumulator Accumulator; *10: SAMSCalculator::aPersistentTape Tape(argv[1]); 11: *12: SAMSCalculator::aController Calculator *13: ( *14: ExternalInterface, *15: Accumulator, *16: Tape *17: ); 18: 19: return ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required