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?