Question: C++ inheritance program: Create a Vehicle class that uses two protected data members to store the fuel capacity and average fuel consumption. The Vehicle class

C++ inheritance program:

Create a Vehicle class that uses two protected data members to store the fuel capacity and average fuel consumption. The Vehicle class should also have the following member functions: A constructor with arguments to initialize data members

A function that computes and returns the distance that can be travelled on a full tank.

Create a Car class that inherits all members from vehicle except constructor (cannot be inherited). Please note that the inherited data members are protected. In addition to the inherited members, the Car class has some specific members as follows:

A data member to store the maximum speed of a car

A constructor with arguments to initialize data members

An operator<<() function that displays the fuel tank capacity, average fuel consumption, maximum speed, and distance that can travelled on a full tank

Design the main() function to instantiate two objects of the Car class and then call the operator<<() function to display all data for these two objects. Please note when the Car constructor is called, the values passed to the constructor can be obtained from the user, or made up by the programmer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!