Chapter 14

1: For each of the following sets of classes, indicate whether public or private derivation is more appropriate for the second column:
class Bearclass PolarBear
class Kitchenclass Home
class Personclass Programmer
class Personclass HorseAndJockey
class Person, class Automobileclass Driver
A1:
class Bearclass PolarBearPublic, a polar bear is a kind of bear
class Kitchenclass HomePrivate, a home has a kitchen
class Personclass ProgrammerPublic, a programmer is a kind of person
class Personclass HorseAndJockeyPrivate, a horse and jockey team contains aperson
class Person, classclass Driver AutomobilePerson public because a driver is a person; Automobile private because a driver has an automobile
2: Suppose we have the following definitions:

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.