Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ 1. Suppose vehicle is a class that defines the basic properties of a vehicle

ID: 3885029 • Letter: C

Question

C++

1. Suppose vehicle is a class that defines the basic properties of a vehicle. Draw a class hierarchy in which several classes are derived from the class vehicle, and then other classes are derived from the classes derived from the class vehicle.

2. Consider the following statements:

In this declaration which class is the base class and which class is the derived class?

What is the type of this inheritance?

3. Consider the following statements:

In this declaration, which class is the base class and which class is the derived class?

What is the type of this inheritance?

4. Explain the difference between overriding and overloading a member function of a base class in a derived class.

5. Consider the following class definitions:

Which private members, if any, of smart are public members if superSmart?

Which members, functions, and/or data of the class smart are directly accessible in class superSmart

6. Explain how the members of a base class are inherited by a derived class using:

private inheritance

protected inheritance

public inheritance

7. Explain the difference between:

The private and protected members of a class.

The protected and public members of a class.

Explanation / Answer

class smart { public: void print() const; void set(int, int); int sum(); smart(); smart(int, int); private: int x; int y; int secret(); }; class superSmart: public smart { public: void print() const; void set(int, int, int); int manipulate(); superSmart(); superSmart(int, int, int); private: int z; }; class smart { public: void print() const; void set(int, int); int sum(); smart(); smart(int, int); private: int x; int y; int secret(); }; class superSmart: public smart { public: void print() const; void set(int, int, int); int manipulate(); superSmart(); superSmart(int, int, int); private: int z; };