|
@@ -3,45 +3,45 @@ using namespace std;
|
|
|
|
|
|
class Vehicle {
|
|
|
public:
|
|
|
- void Run() {
|
|
|
- cout << "Vehicle is running" << endl;
|
|
|
+ virtual void Run() {
|
|
|
+ cout << "vehicle run!" << endl;
|
|
|
}
|
|
|
|
|
|
- void Stop() {
|
|
|
- cout << "Vehicle stops" << endl;
|
|
|
+ virtual void Stop() {
|
|
|
+ cout << "vehicle stop!" << endl;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-class Bicycle : public Vehicle {
|
|
|
+class Bicycle : virtual public Vehicle {
|
|
|
public:
|
|
|
void Run() {
|
|
|
- cout << "Bicycle is running" << endl;
|
|
|
+ cout << "bicycle run!" << endl;
|
|
|
}
|
|
|
|
|
|
void Stop() {
|
|
|
- cout << "Bicycle stops" << endl;
|
|
|
+ cout << "bicycle stop!" << endl;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-class Motorcar : public Vehicle {
|
|
|
+class Motorcar : virtual public Vehicle {
|
|
|
public:
|
|
|
void Run() {
|
|
|
- cout << "Motorcar is running" << endl;
|
|
|
+ cout << "motocar run!" << endl;
|
|
|
}
|
|
|
|
|
|
void Stop() {
|
|
|
- cout << "Motorcar stops" << endl;
|
|
|
+ cout << "motocar stop!" << endl;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
class Motorcycle : public Bicycle, public Motorcar {
|
|
|
public:
|
|
|
void Run() {
|
|
|
- cout << "Motorcycle is running" << endl;
|
|
|
+ cout << "motocycle run!" << endl;
|
|
|
}
|
|
|
|
|
|
void Stop() {
|
|
|
- cout << "Motorcycle stops" << endl;
|
|
|
+ cout << "motocycle stop!" << endl;
|
|
|
}
|
|
|
};
|
|
|
|