October 2011
Beginner to intermediate
1200 pages
35h 33m
English
Student Class ExampleTo get private inheritance, use the keyword private instead of public when defining the class. (Actually, private is the default, so omitting an access qualifier also leads to private inheritance.) The Student class should inherit from two classes, so the declaration should list both:
class Student : private std::string, private std::valarray<double>{public: ...};
Having more than one base class is called multiple inheritance (MI). In general, MI, particularly public MI, can lead to problems that have to be resolved with additional syntax rules. We’ll talk about such matters later in this chapter. But in this particular case, MI causes no problems.
Note that the new class doesn’t need private data. ...
Read now
Unlock full access