Question
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started