File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
basic_content/vptr_vtable Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,11 @@ int main(void)
114114 Base &p = d; // 基类引用指向派生类实例
115115 cout<<"基类对象直接调用"<<endl;
116116 ptr.fun1();
117- cout<<"基类对象调用基类实例 "<<endl;
117+ cout<<"基类引用指向基类实例 "<<endl;
118118 pp.fun1();
119- cout<<"基类指针指向基类实例并调用虚函数 "<<endl;
119+ cout<<"基类指针指向派生类实例并调用虚函数 "<<endl;
120120 pt->fun1();
121- cout<<"基类引用指向基类实例并调用虚函数 "<<endl;
121+ cout<<"基类引用指向派生类实例并调用虚函数 "<<endl;
122122 p.fun1();
123123
124124 // 手动查找vptr 和 vtable
@@ -136,11 +136,11 @@ int main(void)
136136```
137137基类对象直接调用
138138Base::fun1()
139- 基类引用指向派生类实例
139+ 基类引用指向基类实例
140140Base::fun1()
141141基类指针指向派生类实例并调用虚函数
142142Derived::fun1()
143- 基类引用指向基类实例并调用虚函数
143+ 基类引用指向派生类实例并调用虚函数
144144Derived::fun1()
145145=======================
146146vptr_addr:0x401130
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ int main(void)
9090 pp.fun1 ();
9191 cout<<" 基类指针指向派生类实例并调用虚函数" <<endl;
9292 pt->fun1 ();
93- cout<<" 基类引用指向基类实例并调用虚函数 " <<endl;
93+ cout<<" 基类引用指向派生类实例并调用虚函数 " <<endl;
9494 p.fun1 ();
9595
9696
You can’t perform that action at this time.
0 commit comments