Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i want the code in c++ Answer Questions 4. 5. and 6 below given the following class Rental_Car declaration: class Rental_Car{ private: string model; string

i want the code in c++
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Answer Questions 4. 5. and 6 below given the following class Rental_Car declaration: class Rental_Car\{ private: string model; string number; int rental_days; public: Rental_Car(); Rental_Car(string model, string number, int rental_days); void set_number(string number); void set_model(string model); void set_rental_days(int days); string get_model(); string get_number(); int get_rental_days(); virtual double calculate_cost ()=0; //cost of renting the car for rental_days void printData(); //print all object attributes \}: uestion 4 : [ 7 points] Create the derived class Driver_Rental_Car such that: 1) it publicly inherits class Rental_Car [1 point] 2) it has a private data member driver_name (string), and the protected data members daily_cost (float) and fees (float) [ 1 point] 1) write a parametrized constructor - with parameters for all data members in the base class and the derived class [0.5 point] - the constructor should have default arguments for the daily_cost equal to 35 , and for fees equal to 29 [0.5 point] - the constructor should initialize all attributes properly using this pointer explicitly [1 point] 3) write the member function calculate_cost) which should compute and return the cost of renting a car such that the cost would equal: rental_days * daily_cost + fees [1 point] 4) implement the function printData() to print all the attributes of an object of type Driver_Rental_Car [2 point] Question 5: [5 points] 1) Given the prototype of the global function void increaseFees(Driver_Rental_Car \& r, int val); How can we make this function a friend of the class Driver_Rental_Car [1 point] 2) Implement the friend function increaseFees from item (1) of this question such that it adds the amount val to the current value of the attribute fees. [1 point] 3) Overload the operator > as a const member function in class Driver_Rental_Car. - The function receives a constant object of type Driver_Rental_Car by reference. The function returns true if the renting cost of the calling object is greater than the renting cost of object passed as an argument. It should return false otherwise. [3 point] Question 6: [ 10 points] In the main function: 1) create a const Driver_Rental_Car object with any prober values and name it drc 2) declare a pointer of type Rental_Car and call it roptr 3) create a Driver_Rental_Car object dynamically with any prober values and make the pointer reptr points to it. 4) call printData using reptr, would this call the function in Rental_Car class or in Driver_Rental_Car class. 5) call calculate_cost using reptr, would this call the function in Rental_Car class or in Driver_Rental_Car class? 6) call the overloaded operator function to test if the object pointed to by reptr has a greater rental cost than the object drc or not. 7) free the memory pointed to by the pointer ,rcptr 8) if we have the class Company_Rental_Car, which inherits class Rental_Car, can we use the pointer reptr to point to the object crc of type Company_Rental_Car after implementing (7)? Briefly explain your answer. 9) Can we pass the object crc from (8) as an argument to the function operator of class Driver_Rental_Car? Briefly explain your answer. 10) is the following declaration correct in the main function? explain your answer. Rental_Car rentalCar1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

4 ) - - IC) (chr ) 4 ) - - IC) (chr )

Answered: 1 week ago