C++ 虚函数表详解:探秘虚函数地址及调用机制
#include
//请仿造上面的方法,改动程序相应的语句,能够分别输出Base::g()和Base::h()的函数地址。
// (Fun)((int)(int)(&b)+0); // Base::f()
// (Fun)((int)(int)(&b)+1); // Base::g()
// (Fun)((int)(int)(&b)+2); // Base::h()
}
|-----------------| | Base::f() | |-----------------| | Base::g() | |-----------------| | Base::h() | |-----------------|
原文地址: https://www.cveoy.top/t/topic/nOt2 著作权归作者所有。请勿转载和采集!