Choosing a Technique for Code Reuse

In this section, I will discuss the relative advantages and disadvantages of using inheritance and composition. Both relationships are client-server relationships. A derived class is a client of the base class, and the base class is a server of the derived class. A composite class is a client of its component class, and the component class is a server of the composite class. This means that you are going to see significant similarities between C++ programs built with alternative design techniques.

The common feature of different design solutions is the division of work between the client and the server classes, be it with the use of composition or any other design techniques. This means that the server class ...

Get Core C++ A Software Engineering Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.