Object Composition and Separate Compilation

In this lab you will be using the Car class that you have designed in Lab 2. It is important that you have completed and tested Lab 2 before proceeding.



There are two steps to this lab:

1. Split your program into 3 files: Car.h, Car.cpp and client.cpp. Car.h contains the class declaration, Car.cpp contains the definitions of the Car member functions, and client.cpp contains the main program.

2. Write a new class called Carrental using the .h and .cpp model, which includes:

Member Variables:
  1. Carinfo: of type Car.
  2. mileage: of type int.
  3. cost: of type double.
  4. available: type bool.
Member Functions:
  1. A constructor that accepts a year, make, speed, mileage, and cost and initializes all member variables.
  2. isavailable: return a bool.
  3. cartype: return a string, which is the make of the Carinfo object.

3. Now, modify your client.cpp program to instantiate a Carrental object. Display all member variables and test all of the functions.