Section 21:
 21.1 Should I hide member functions that were public in my base class? 21.2 Errors trying to convert Derived** → Base**? 21.3 Is a parking-lot-of-Car a kind-of parking-lot-of-Vehicle? 21.4 Is an array of Derived a kind-of array of Base? 21.5 Does array-of-Derived is-not-a-kind-of array-of-Base mean arrays are bad? 21.6 Is a Circle a kind-of an Ellipse? 21.7 Are there other options to the "Circle is/isnot kind-of Ellipse" dilemma? 21.8 Why does this Circle-kind-of-Ellipse problem seem confusing? 21.9 Perhaps Ellipse should inherit from Circle then? 21.1 But my problem doesn't have anything to do with circles and ellipses, so what good is that silly example to me? 21.11 How could "it depend"??!? Aren't terms like "Circle" and "Ellipse" defined mathematically? 21.12 Is SortedList a kind-of List?
[21.6] Is a Circle a kind-of an Ellipse?

Depends. But not if Ellipse guarantees it can change its size asymmetrically.

For example, if Ellipse has a setSize(x,y) member function that promises the object's width() will be x and its height() will be y, Circle can't be a kind-of Ellipse. Simply put, if Ellipse can do something Circle can't, then Circle can't be a kind of Ellipse.

This leaves two valid relationships between Circle and Ellipse:

• Make Circle and Ellipse completely unrelated classes
• Derive Circle and Ellipse from a base class representing "Ellipses that can't necessarily perform an unequal-setSize() operation"

In the first case, Ellipse could be derived from class AsymmetricShape, and setSize(x,y) could be introduced in AsymmetricShape. However Circle could be derived from SymmetricShape which has a setSize(size) member function.

In the second case, class Oval could only have setSize(size) which sets both the width() and the height() to size. Ellipse and Circle could both inherit from Oval. Ellipse —but not Circle— could add the setSize(x,y) operation (but beware of the hiding rule if the same member function name setSize() is used for both operations).

(Note: this FAQ has to do with public inheritance; private and protected inheritance are different.)

(Note: setSize(x,y) isn't sacred. Depending on your goals, it may be okay to prevent users from changing the dimensions of an Ellipse, in which case it would be a valid design choice to not have a setSize(x,y) method in Ellipse. However this series of FAQs discusses what to do when you want to create a derived class of a pre-existing base class that has an "unacceptable" method in it. Of course the ideal situation is to discover this problem when the base class doesn't yet exist. But life isn't always ideal...)