Write in full the STACK class and its heir ARRAYED_STACK sketched in this chapter, using the "marriage of convenience" technique.
Imagine the classification of kinds of inheritance were an inheritance hierarchy. What kind or kinds would it involve?
(This exercise comes from an example used by Philippe Drix on the French GUE electronic mailing list, late 1995 and early 1996.)
Assume a deferred class STACK with a procedure put to push an element onto the top, with a precondition involving the boolean-valued function full (which could also be called extendible; as you study the exercise you will note that the choice of name may affect the appeal of various possible solutions).
Now consider the famous problem of the Towers of Hanoï, where disks are stacked on piles --- the towers --- with the rule that a disk may only be put on a larger disk.
Is it appropriate to define the class HANOÏ_STACK, representing such piles, as an heir to STACK? If so, how should the class be written? If not, can HANOÏ_STACK still make use of STACK? Write the class in full for the various possible solutions; discuss the pros and cons of each, state which one you prefer, and explain the rationale for your choice.
Provide one or more examples of functional variation inheritance. For each of them, discuss whether they are legitimate applications of the open-closed principle or examples of what the discussion called "disciplined hacking".
For each of the following cases, indicate which one of the inheritance kinds applies:
Would it be a good idea to have iterator features (while_do and the like) included in classes describing the data structures on which they iterate, such as LIST? Consider the following points: