downcast problem in c++
<pre><code>#include &lt;iostream&gt;
using std::cout;
using std::endl;
class Base
{
public :
    void f();
    void g();

    int mBaseData1;

};

class Derived : public Base
{
public : 


    int mDerivedData1;
};

void main()
{

    Base* base = new Base();
    Derived* derived = (Derived*)(base); // DownCast
    derived-&gt;mDerivedData1 = 6;
    cout&lt;&lt; derived-&gt;mDerivedData1&lt;&lt;endl; // Result = 6;
}
</code></pre>

<p>in this code  <code>new base()</code> allocate memory in heap </p>

<p>and <code>Derived* derived = (Derived*)(base)</code> cast base to derived </p>

<p>how we can use mDerivedData1? i cant find where we allocate memory for mDerivedData1  or when we call constructor of Derived for allocate mDerivedData1 ?</p>
