Derived
あるクラス(の基本クラス)のオブジェクトを割り当て、Base
そのオブジェクトへのポインターを基本クラスを指す変数に格納すると、どのようにDerived
クラスのメンバーにアクセスできますか?
次に例を示します。
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?