[fdj@hs-192-168-33-206 virtbl]$ vi main.cpp
CTest(int data, int* p);
virtual void show();
void print();
private:
int a;
int *ptr;
};
CTest::CTest(int data, int* p):a(data), ptr(p){
}
void CTest::show(){
cout<<"in show"<<endl;
}
void CTest::print(){
cout<<"in print"<<endl;
}
typedef void (CTest::*func)();
int main(){
int value = 100;
CTest obj(5, &value);
CTest* lpObj = &obj;
cout<<"system ptr size = "<< sizeof(lpObj)<<endl;
func f = &CTest::show;
(lpObj->*f)();
cout<<"addr:" << f<<endl;
//如果对象内存首部是vptr指针的内存,指针是8字节的内存 64位
long long* vptr = (long long*)(lpObj);
//vptr 指向 虚表的 type