Question: #include #include class Vehicle { protected: std::string brand; int capacity; public: Vehicle ( const std::string& brand, int capacity ) : brand ( brand ) ,

#include
#include
class Vehicle {
protected:
std::string brand;
int capacity;
public:
Vehicle(const std::string& brand, int capacity)
: brand(brand), capacity(capacity){}
virtual void move()=0;
};
class Car : public Vehicle {
private:
std::string model;
int year;
public:
Car(const std::string& brand, const std::string& model, int year)
: Vehicle(brand,5), model(model), year(year){}
void move() override {
std::cout << "Driving the car: "<< brand <<""<< model <<""<< year << std::endl;
}
};
class Train : public Vehicle {
private:
std::string name;
public:
Train(const std::string& name, int capacity)
: Vehicle("Train", capacity), name(name){}
void move() override {
std::cout << "The train "<< name <<" is running with a capacity of "<< capacity <<" passengers." << std::endl;
}
};
int main(){
Car myCar("Toyota", "Camry", 2020);
Train myTrain("Express",300);
myCar.move();
myTrain.move();
return 0;
}Please represent this code in UML

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!