Using a Derived Class
To use a derived class, a program needs access to the base-class declarations. Listing 13.4 places both class declarations in the same header file. You could give each class its own header file, but because the two classes are related, it makes more organizational sense to keep the class declarations together.
Listing 13.4. tabtenn1.h
// tabtenn1.h -- a table-tennis base class#ifndef TABTENN1_H_#define TABTENN1_H_#include <string>using std::string;// simple base classclass TableTennisPlayer{private: string firstname; string lastname; bool hasTable;public: TableTennisPlayer (const string & fn = "none", const string & ln = "none", bool ht = false); void Name() const; bool HasTable() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access