下面代码中 v1、v2 调用相同接口 move() 但输出不同,体现了面向对象的( )特性。
class Vehicle { ... virtual void move() const { ... } };
class Car : public Vehicle { void move() const override { ... } };
class Bike : public Vehicle { void move() const override { ... } };
Vehicle* v1 = new Car("Toyota", 5);
Vehicle* v2 = new Bike("Giant");
v1->move(); v2->move();
- A. 继承 (Inheritance)
- B. 封装 (Encapsulation)
- C. 多态 (Polymorphism)
- D. 链接 (Linking)
正确答案:C