0% found this document useful (0 votes)
8 views1 page

Vehicle Inherit

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Vehicle Inherit

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream>

#include<string>
using namespace std;

class Vehicle{
private:
string brand, model;

protected:
int year;
string color;

public:
void setDetails(string brnd, string mdl, int yr, string col){
brand = brnd;
model = mdl;
year = yr;
color = col;
}

void displayDetails(){
cout << "Brand: " << brand << endl;
cout << "Model: " << model << endl;
cout << "Year: " << year << endl;
cout << "Color: " << color << endl;
}
};

class ElectricVehicle : public Vehicle{


private:
double batteryCapacity;

public:
void setBatteryCapacity(double capacity){
batteryCapacity = capacity;
}

void showElectricVehicleInfo(){
displayDetails();
cout << "Battery Capacity: " << batteryCapacity << " KW" << endl;
}
};

int main(){

ElectricVehicle ev;
ev.setDetails("Rolls Royace", "Spectre", 2024, "Infinity Black");
ev.setBatteryCapacity(102);
ev.showElectricVehicleInfo();

return 0;
}

You might also like