C++ Access derived class member from base class pointer
问题 If I allocate an object of a class Derived (with a base class of Base ), and store a pointer to that object in a variable that points to the base class, how can I access the members of the Derived class? Here's an example: class Base { public: int base_int; }; class Derived : public Base { public: int derived_int; }; Base* basepointer = new Derived(); basepointer-> //Access derived_int here, is it possible? If so, then how? 回答1: No, you cannot access derived_int because derived_int is part of