// It works for VC6 implementations, didn't check in other compilers! #include <windows.h> class CTest { public: virtual void bla() { MessageBox(NULL, "bla1", "CTest", 0); } virtual void bla2() { MessageBox(NULL, "bla2", "CTest", 0); } virtual void bla3() { MessageBox(NULL, "bla3", "CTest", 0); } };
typedef (*lpfunc)(void* thisptr); lpfunc func;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CTest* ct = new CTest; DWORD *pvtbl = (DWORD*)ct; DWORD *vtbl = (DWORD*)*pvtbl; func = (lpfunc)vtbl[1]; func(ct); delete ct; return 0; } |