I can't display variables of different types included in array
<p>I have to do a program for college. </p>

<p>I have 3 classes already declared in the statement of the problem.
First class:</p>

<pre><code>class piesa_a{
protected:

    int id;
    char *tip;
    int pret;
};
</code></pre>

<p>Second class:</p>

<pre><code>class piesa_b:public piesa_a
{

private:
    float lungime;
    bool bw;
};
</code></pre>

<p>Third class:</p>

<pre><code>class piesa_c:public piesa_a
{

private:
    int nr;
    piesa_b *buf;
};
</code></pre>

<p>In main I need to create an array in which to store items such piesa_a, piesa_b, piesa_c. Then I have to sort items by price.</p>

<p><strong>I have this code so far:</strong> <a href="http://pastebin.com/nx2FGSfe" rel="nofollow">http://pastebin.com/nx2FGSfe</a></p>

<p>The program is incomplete because it does not displays each item in the array.</p>

<p>I got stuck here. But if you display the array's elements when they are outside of it, it works.</p>

<p><strong>SHORT:</strong> I have an error on line 143 and I want to solve it.</p>

<pre><code>main.cpp:143:18: error: request for member ‘afisare’ in ‘*(v + ((unsigned int)(((unsigned int)i) * 4u)))’, which is of non-class type ‘piesa_a*’
</code></pre>

<p>The code is here:</p>

<pre><code>#include &lt;cstdlib&gt;
#include&lt;iostream&gt;
#include&lt;string.h&gt;
using namespace std;

class piesa_a{

protected:

    int id;
    char *tip;
    int pret;

public:
    piesa_a()
        {
            id = 0;
            tip = new char[1];
            pret = 0;
        }
    piesa_a(int aidi, char *typ, int pretz)
            {

        id = aidi;
        tip = new char[strlen(typ)+1];
        strcpy(tip,typ);
        pret = pretz;

            }
    piesa_a&amp;operator =(piesa_a alta)
    {
        id = alta.id;
        tip = new char[strlen(alta.tip)+1];
        strcpy(tip,alta.tip);
        pret = alta.pret;

        return *this;
    }

   virtual void afisare()
    {
        cout&lt;&lt;"\n Piesa A: "&lt;&lt;id&lt;&lt;" "&lt;&lt;tip&lt;&lt;" "&lt;&lt;pret;
    }

};

class piesa_b:public piesa_a
{

private:
    float lungime;
    bool bw;
public:
    piesa_b():piesa_a(){lungime = 0;bw = 0;}
    piesa_b(float lg,bool bl, int aid, char *tipi, int pretzz):piesa_a(aid,tipi,pretzz)
    {
        lungime = lg;
        bw = bl;
    }
    piesa_b&amp;operator =(piesa_b &amp;c)
    {
        id = c.id;
        tip = new char[strlen(c.tip)+1];
        strcpy(tip,c.tip);
        pret = c.pret;
        lungime = c.lungime;
        bw = c.bw;

        return *this;
    }

    void afisare()
    {
        piesa_a::afisare();
        cout&lt;&lt;"impreuna cu piesa B: "&lt;&lt;lungime&lt;&lt;" "&lt;&lt;bw&lt;&lt;"\n";
    }

};

class piesa_c:public piesa_a
{

private:
    int nr;
    piesa_b *buf;
public:
    piesa_c():piesa_a(){nr=0; buf = new piesa_b[nr];}
    piesa_c(int n, piesa_b *bu,int aid, char *tipi, int pretzz):piesa_a(aid,tipi,pretzz)
    {
        nr = n;
        buf = new piesa_b[nr];
        for(int i=0;i&lt;nr;i++)
            buf[i]= bu[i];
    }
    piesa_c&amp;operator =(piesa_c &amp;alta)
    {

        id = alta.id;
        tip = new char[strlen(alta.tip)+1];
        strcpy(tip,alta.tip);
        pret = alta.pret;
        nr = alta.nr;
        for(int i=0;i&lt;alta.nr;i++)
            buf[i] = alta.buf[i];

    }

    void afisare()
    {

        for(int i=0;i&lt;nr;i++)
            buf[i].afisare();

    }

};

int main(int argc, char** argv) {

    piesa_b *H;
            H = new piesa_b[2];

    piesa_a A(4,"TIPA",120);
    piesa_b B(100,1,3,"TIPA",120);
    H[0]=B;
    H[1]=B;
    piesa_c C(2, H,14,"TIPC",20);

    piesa_a** v = new piesa_a*[3];

    v[0] = &amp;A;
    v[1] = &amp;B;
    v[2] = &amp;C;

    for(int i=0;i&lt;3;i++)
        v[i].afisare();

    return 0;
}
</code></pre>

<p>What's wrong?</p>
