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{
    protected:
        int mileage, price;
    public:
        Vehicle(int m, int p): mileage(m), price(p){}
};
class Car:public Vehicle{
    int cost, warranty, capacity;
    string fuel;
    public:
        Car(int m, int p, int c, int w, int cap, string f):
            Vehicle(m, p), cost(c), warranty(w), capacity(cap), fuel(f){}
};
class Bike:public Vehicle{
    int cylinders, gears;
    string cooling;
    public:
        Bike(int m, int p, int c, int g, string s):Vehicle(m, p), cylinders(c), gears(g), cooling(s){}
};
Comments