We want to store the information of different vehicles. Create a class named Vehicle with two data member named mileage and price. Create its two subclasses
*Car with data members to store ownership cost, warranty (by years), seating capacity and fuel type (diesel or petrol).
*Bike with data members to store the number of cylinders, number of gears, cooling type (air, liquid or oil).
#include <iostream>
using namespace std;
class Vehicle
{
private:
double mileage;
double price;
};
class Car: public Vehicle
{
private:
double ownershipCost;
int warranty;
int seatingCapacity;
string fuelType;
};
class Bike: public Vehicle
{
private:
int numberOfCylinders;
int numberOfGears;
string coolingType;
};
Comments
Leave a comment