摘要
介绍了C++编程语言中的虚函数及其在进行面向对象程序设计中重要性,并且详细阐述了它在编译器底层虚函数的实现机制.它通过一个vptr和vtable在运行时进行动态绑定,从而能够根据对象类型的不同调用不同的虚函数;并通过实例测试验证了上述机制.
The virtual function in C+G-+ and its importance are introduced in this article, and the implementation mechanism of the virtual function is expounded in detail. It is dynamically bound through a virtual pointer(vptr) and virtual table during the running time, and so different class virtual function are called by the object′s type; and this mechanism is verified through a testing program.
出处
《天津理工学院学报》
2004年第3期65-67,共3页
Journal of Tianjin Institute of Technology
基金
天津市自然科学基金资助项目(033600211)