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); ...

Get C++ Primer Plus, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.