Vehicle Inherit
Vehicle Inherit
#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;
}
};
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;
}