O'Reilly logo

C++ Primer Plus, Fourth Edition by Stephen Prata

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

Beginning with a Simple Base Class

When one class inherits from another, the original class is called a base class and the inheriting class is called a derived class. So, to illustrate inheritance, we need to begin with a base class. The Webtown Social Club has decided to keep track of those members who play table tennis. As head programmer for the club, you have designed the simple TableTennisPlayer class defined by Listings 13.1 and 13.2.

Listing 13.1. tabtenn0.h
 // tabtenn0.h #ifndef TABTENN0_H_ #define TABTENN0_H_ // simple base class class TableTennisPlayer { private: enum { LIM = 20}; char firstname[LIM]; char lastname[LIM]; bool hasTable; public: TableTennisPlayer (const char * fn = "none", const char * ln = "none", bool ht = false); ...

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