C++ base class pointer calls child virtual function, why could base class pointer see child class member
问题 I think I might be confusing myself. I know class with virtual functions in C++ has a vtable (one vtable per class type), so the vtable of Base class will have one element &Base::print() , while the vtable of Child class will have one element &Child::print() . When I declare my two class objects, base and child , base 's vtable_ptr will pointer to Base class's vtable, while child 's vtable_ptr will point to Child class's vtable. After I assign the address of base and child to an array of Base