Perhaps a more appropriate title for this chapter would have been “Reusable Data Structures.” Comment on how each of the following entities or concepts contributes to the reusability of data structures:
a) classes
b) class template
b) class template
d) private inheritance
e) composition
a) Classes allow us to instantiate as many data structure objects of a certain type (i.e.,
class) as we wish.
b) Class templates enable us to instantiate related classes, each based on different type
parameters—we can then generate as many objects of each template class as we like.
c) Inheritance enables us to reuse code from a base class in a derived class, so that the
derived-class data structure is also a base-class data structure (with public inheritance,
that is).
d) Private inheritance enables us to reuse portions of the code from a base class to form
a derived-class data structure; because the inheritance is private, all public base-class
member functions become private in the derived class. This enables us to prevent
clients of the derived-class data structure from accessing base-class member functions
that do not apply to the derived class.
e) Composition enables us to reuse code by making a class object data structure a member
of a composed class; if we make the class object a private member of the composed
class, then the class object’s public member functions are not available through the composed object’s interface.
You might also like to view...
Which of the following is not a standard C formatted stream?
a) standard input stream b) standard error stream c) standard output stream d) standard redirection stream
In the Properties pane of the CSS Styles panel, when a property in another rule overrides the same property in the selected rule, how does the property in the selected rule display?
A. With a red line through it B. With a dashed line through it C. In boldface D. In italics