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