除了作为抽象类的派生类对象的一部分,是不能够生成抽象基类对象的。
We may not create objects of an abstract type except as parts of objects of classes derived from the abstract base.
使用基类对象指针或引用的函数必须能够在不了解衍生类的条件下使用衍生类的对象。
Functions that use Pointers or references to base classes must be able to use objects of derived classes without knowing it.
你只需要将对象上传转化为基类对象不需要知道额外的信息,而这些都是通过多态实现的。
All you need to do is upcast from the derived class and never look back to see what exact type of object you're dealing with. Everything is handled through polymorphism.
应用推荐