CS3240: Data Structures and Algorithms

C++: Set 1Discussion Questions

1. Assume a class D that is privately derived from class B.  An object of class D in main() can access

a. public members of D.
b. protected members of D.
c. private members of D.
d. public members of B.
e. protected members of B.
f. private members of B.
 

 

2. A class D can be derived from a class C, which is derived from a class B, which is derived from a class A.

a. True
b. False

3. Assume a class D derived from a base B. Both classes contain a member function foo() that takes no arguments. Write a statement that is in a member function of D that calls foo() in the base class.

B::foo();

4. Write the first line of a specifier for a class AB that is derived from class A and from class B.

class AB : public A, public B

5. Assume a base class B with a public member function bFunc(), and class D is derived from B. Write a statement that allows an object of D to access bFunc().

obj.bFunc(); // assume obj is an instance of D

 

6. It is illegal to make objects of one class members of another class.

a. True
b. False

 

© Lynne Grewe