Question: #include using namespace std; / / Base class class Road { string name; int numberOfLanes; int maximumSpeed; public: Road ( string n , int l
#include
using namespace std;
Base class
class Road
string name;
int numberOfLanes;
int maximumSpeed;
public:
Roadstring nint lint s
name n;
ifl
numberOfLanes l;
else
int x;
whilex
cout
Enter valid number of lanes";
cinx;
numberOfLanes x;
ifs && s
maximumSpeed s;
else
int x;
whilex && x
cout
Enter valid maximum speed";
cinx;
maximumSpeed x;
void toString
cout
Road Name :
numberOfLanes l;
else
int x;
whilex
cout
Enter valid number of lanes";
cinx;
numberOfLanes x;
void setSpeedint s
condition for valid maximumSpeed
ifs && s
maximumSpeed s;
else
int x;
whilex && x
cout
Enter valid maximum speed";
cinx;
maximumSpeed x;
Getter function
string getName
return name;
int getNumberOfLanes
return numberOfLanes;
int getMaximumSpeed
return maximumSpeed;
;
TollRoad class inherit the Road class
Derived class
class TollRoad : public Road
int toll;
public:
parameterized constructor
TollRoadstring name,int lint sint t:Roadnamels pass value to base class constructor
condition for valid Toll value
ift
toll t;
else
int x;
whilex
cout
Enter toll value greater than : ;
cinx;
toll x;
setter function
void setTollint t
condition for valid Toll value
ift
toll t;
else
int x;
whilex
cout
Enter toll value greater than : ;
cinx;
toll x;
int getToll getter method
return toll;
void TolltoString to string method
toString;
cout
Toll Value :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
