Virtual Functions Object Slicing
问题 My question is with reference to this question which explains how virtual functions work in case of object slicing which end up calling base class virtual function and Wikipedia article which explains the virtual table layout for a derived class for below code class A{ public: virtual void func(){ cout<<"\n In A:func";} }; class B:public A{ public: virtual void func(){ cout<<"\n In B:func";} }; main(){ A *ptr1 = new B(); A oA = *ptr1; oA.func(); } DerviedClassObjectB: +0: pointer to virtual