前篇: http://blog.sina.com.cn/s/blog_5f5fff010100cvde.html
下面的代码中,类Base中定义了两个虚函数vfBase_1()和vfBase_2(),另外还定义了一个整形成员变量m_base;
#include <iostream>
using namespace std;
class Base
{
public:
};
// 定义一个函数指针类型,返回值类型为void,参数类型为void
typedef void (*VFun)(void);
// 获取虚函数表中的虚函数指针,其中b为带有虚函数的类的对象的地址,i为虚函数表中虚函数的顺序
VFun virtualFunctionPointer(Base* b, int i)
{
}
int main(void)
{
}
运行结果为:
