Question
For C++ -- Create a class called Auto. Class Auto has three private member variables. string make, string model and double price. Class Auto has
For C++ --
Create a class called Auto. Class Auto has three private member variables. string make, string model and double price. Class Auto has a parametrized constructor that accepts arguments for make, model and price and sets the values of the three member variables, make, model and price. Class Auto has three accessor member functions getmake(), getmodel() and getprice() that return the values of make, model and price respectively.
Class Car inherits from class Auto. Class car has one private member, int doors. Car class has a parametrized constructor that accepts arguments for make, model, price and doors and passes make, model, price to base class constructor and sets the value of member variable doors. Class Car has one public member function getdoors(0 that returns the number of doors the car has. It also has a public function double bookvalue(int years), that accepts an argument for number of years the car is old and returns the depreciated value (book value) of the car by reducing price of the car by 7% for each year the car has been in existence. Class Truck inherits from class Auto and has one private member variable, capacity. It has a parametrized constructor that accepts arguments for make, model, price and capacity and passes make, model, price to base class constructor and sets the value of member variable capacity (measured in tons). Class Truck has a public member function getcapacity() that returns the capacity of the truck. In a client program, create a car object and a truck object. Display the make, model, price (and doors and book value for car object) and (capacity for the truck object).
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