#include <iostream>
using namespace std;
class Base
{
virtual void f() {cout << "f()" << endl;}
virtual void g() {cout << "g()" << endl;}
virtual void h() {cout << "h()" << endl;}
};
typedef void(*pFun)(void);
int main()
{
Base b;
pFun p = (pFun)*(long *)*(long *)(&b);
p();
p = (pFun)*((long *)*(long *)(&b) + 1);
p();
p = (pFun)*((long *)*(long *)(&b) + 2);
p();
pFun **table = (pFun **)&b;
p = table[0][0];
p();
p = table[0][1];
p();
p = table[0][2];
p();
return 0;
}
output:
f
g
h
f
g
h