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
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:
class personalComputers: public computers
{ . . . };
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:
class fruits: food
{ . . .
};
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:
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;
};
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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
