Use a class as a BaseClass
<p>I have:</p>

<pre><code>class BASE{
public:
    virtual void func1() = 0;
};
</code></pre>

<p>Then i have some derived classes, like:</p>

<pre><code>class Derived1 : public BASE{
public:
    void func1() {...implementation....}
};

class Derived2 : public BASE{
    public:
        void func1() {...implementation....}
    };
</code></pre>

<p>In the main i would like to do something like (pseudo code):</p>

<pre><code>if ( cond ){
   BASE b := new Derived1
}
else{
   BASE b := new Derived2
}
b.func1();
</code></pre>

<p>so that the func1() fuction invoked is the one specialized for the derived class.</p>

<p>I tried to do:</p>

<pre><code>BASE b = new Derived1();
</code></pre>

<p>but the compiler complain.</p>

<p>Is it possible to do that in C++? How?</p>

<p>Thank you.</p>
