Answers to these questions.
1. Inheritance is a way to
a. make general classes into more specific classes.
b. pass arguments to objects of classes.
c. add features to existing classes without rewriting them.
d. improve data hiding and encapsulation.
2. A “child” class is said to be _________ from a base class.
3. Advantages of inheritance include
a. providing class growth through natural selection.
b. facilitating class libraries.
c. avoiding the rewriting of code.
d. providing a useful conceptual framework.
4. Write the first line of the specifier for a class Bosworth that is publicly derived from a
class Alphonso.
5. True or false: Adding a derived class to a base class requires fundamental changes to the
base class.
6. To be accessed from a member function of the derived class, data or functions in the base
class must be public or _________.
7. If a base class contains a member function basefunc(), and a derived class does not contain
a function with this name, can an object of the derived class access basefunc()?
8. Assume that the classes mentioned in Question 4 and the class Alphonso contain a member
function called alfunc(). Write a statement that allows object BosworthObj of class
Bosworth to access alfunc().
True or false: If no constructors are specified for a derived class, objects of the derived
class will use the constructors in the base class.
10. If a base class and a derived class each include a member function with the same name,
which member function will be called by an object of the derived class, assuming the
scope-resolution operator is not used?
11. Write a declarator for a no-argument constructor of the derived class Bosworth of
Question 4 that calls a no-argument constructor in the base class Alphonso.
12. The scope-resolution operator usually
a. limits the visibility of variables to a certain function.
b. tells what base class a class is derived from.
c. specifies a particular class.
d. resolves ambiguities.
13. True or false: It is sometimes useful to specify a class from which no objects will ever be
created.
14. Assume that there is a class Derv that is derived from a base class Base. Write the
declarator for a derived-class constructor that takes one argument and passes this argument
along to the constructor in the base class.
15. Assume a class Derv that is privately derived from class Base. An object of class Derv
located in main() can access
a. public members of Derv.
b. protected members of Derv.
c. private members of Derv.
d. public members of Base.
e. protected members of Base.
f. private members of Base.
16. True or false: A class D can be derived from a class C, which is derived from a class B,
which is derived from a class A.
17. A class hierarchy
a. shows the same relationships as an organization chart.
b. describes “has a” relationships.
c. describes “is a kind of” relationships.
d. shows the same relationships as a family tree.
18. Write the first line of a specifier for a class Tire that is derived from class Wheel and
from class Rubber.
19. Assume a class Derv derived from a base class Base. Both classes contain a member
function func() that takes no arguments. Write a statement to go in a member function
of Derv that calls func() in the base class.
20. True or false: It is illegal to make objects of one class members of another class.