摘要
多态性是C++的一个关键技术。在教学过程中,学生对多态性理解起来有一定的难度,尤其是动态多态性,它的实现基础是类继承关系和虚函数。分析包含虚函数的类的虚函数表及其定义的对象中的虚表指针,并结合实例来探讨单继承和多重继承下的动态多态性的实现机制。
Polymorphism is one of the important technologies of C++. During the whole teaching process, it's difficult for students to comprohend these knowledge,especially dynamic polymorphism, its foundation is virtual function. Analyzes virtual tables for a class which has some virtual functions and vfptr for class object, also discusses the implementation mechanism of dynamic polymorphism according to different kinds of inheritance relationship by taking many programming samples.
出处
《现代计算机》
2009年第11期108-111,共4页
Modern Computer
关键词
多态性
虚函数
虚函数表
虚表指针
Polymorphism
Virtual Function
Virtual Table
Vfptr