在这种情况下,Shape的area()方法(译注:得到Shape面积的成员函数)必须是virtual的(可能是纯虚(pure-virtual)的),但Shape::print()可以在Shape中被定义为非虚(non-virtual)的,前提是所有派生类不会需要不同的打印算法。
基于16个网页-相关网页
为纯虚函数所生成的代码如列表 1 中所示。
The code generated for the pure virtual function is shown in Listing 1.
这个例子的性能和纯虚函数表例子是相同的。
The performance of this sample and the pure vtable-based sample are exactly identical.
类包含或者继承一个或多个纯虚函数,这样的类就是抽象基类。
A class containing (or inheriting) one or more pure virtual functions is an abstract base class.
应用推荐