doc is not consistent with code in vptr_vtable
This commit is contained in:
parent
ade7173887
commit
f6994de797
@ -114,11 +114,11 @@ int main(void)
|
||||
Base &p = d; // 基类引用指向派生类实例
|
||||
cout<<"基类对象直接调用"<<endl;
|
||||
ptr.fun1();
|
||||
cout<<"基类对象调用基类实例"<<endl;
|
||||
cout<<"基类引用指向基类实例"<<endl;
|
||||
pp.fun1();
|
||||
cout<<"基类指针指向基类实例并调用虚函数"<<endl;
|
||||
cout<<"基类指针指向派生类实例并调用虚函数"<<endl;
|
||||
pt->fun1();
|
||||
cout<<"基类引用指向基类实例并调用虚函数"<<endl;
|
||||
cout<<"基类引用指向派生类实例并调用虚函数"<<endl;
|
||||
p.fun1();
|
||||
|
||||
// 手动查找vptr 和 vtable
|
||||
@ -136,11 +136,11 @@ int main(void)
|
||||
```
|
||||
基类对象直接调用
|
||||
Base::fun1()
|
||||
基类引用指向派生类实例
|
||||
基类引用指向基类实例
|
||||
Base::fun1()
|
||||
基类指针指向派生类实例并调用虚函数
|
||||
Derived::fun1()
|
||||
基类引用指向基类实例并调用虚函数
|
||||
基类引用指向派生类实例并调用虚函数
|
||||
Derived::fun1()
|
||||
=======================
|
||||
vptr_addr:0x401130
|
||||
|
@ -90,7 +90,7 @@ int main(void)
|
||||
pp.fun1();
|
||||
cout<<"基类指针指向派生类实例并调用虚函数"<<endl;
|
||||
pt->fun1();
|
||||
cout<<"基类引用指向基类实例并调用虚函数"<<endl;
|
||||
cout<<"基类引用指向派生类实例并调用虚函数"<<endl;
|
||||
p.fun1();
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user