Question: c++ Inheritance example: Define a vehicle class that stores the vehicles id as a string and wheels as protected members . Add appropriate constructors, accessor
c++
Inheritance example:
Define a vehicle class that stores the vehicles id as a string and wheels as protected members. Add appropriate constructors, accessor functions, and mutator functions. Also define a function named get_toll that returns an int with the value 4*wheels.
int get_toll();
Next, define a bike class that is derived from vehicle. The bike class should have a private member variable named pedals that stores whether the bike has pedals below the rider or in front of the rider . Add appropriate constructors, mutator functions, and accessor functions for the bike class and pedals variable. Redefine theget_toll() function to returns 0 for the cost of a bikes toll if the pedals are below the rider and 1 if the pedals are in front of the user.
In the driver,
Be able to create a vehicle object and bike pointer, set the data members and print the toll for a vehicle object. Ask the user for the number of bikes and create a dynamic array of bikes. Ask the user for the information to set the data members for each bike object. Print the toll for all the bikes. Make sure you have no memory leaks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
