#include
typedef void (*pfn_t) (void *);
class CObject
{
char *m_pszStr;
virtual void vfunc()
{
m_pszStr = "Slash is the BEST!\n";
cout << m_pszStr;
}
};
main()
{
CObject a;
pfn_t **p;
p = (pfn_t **) & a;
(**p) (&a);
}
執行結果:
[slash@slash ~]$ g++ -Wno-deprecated a.cpp
[slash@slash ~]$ ./a.out
Slash is the BEST!
[slash@slash ~]$