int main()
{

   Ferma *f[20];
   int i=0;

    int e=0;
    do
    {
        cout<<"Alegeti optiunea:\n";
        cout<<"1.rata\n"
            <<"2.gaina\n"
            <<"3.porc\n"
            <<"4.vaca\n"
            <<"0.iesire\n";
        cin>>e;
        switch(e)
        {
        case 1:
            f[i]=new Pasari("rata"); //error at this kind of assignement
            i++;
            break;
        case 2:
            f[i]=new Pasari("gaina");
            i++;
            break;
        case 3:
            f[i]=new Mamifere("porc");
            i++;
            break;
        case 4:
            f[i]=new Mamifere("vaca");
            i++;
            break;
        case 0:cout<<"Ai ales sa iesi\n";
            break;
        }

    } while((e!=0) || (i<5));

    cout<<"Ferma contine "<<Ferma::nr_rate+Ferma::nr_gaini+Ferma::nr_porci+Ferma::nr_vaci<<":";

    for(int c=0;c<=i;c++)
        (*f[c]).afisare();


        return 0;

}

Incearca sa schimbe linia #39 din || la &&

>> while((e!=0) || (i<5));

I think you want to change that to while((e!=0) && (i<5)); I would suggest restructuring your program using functions and std::vector

Incearca sa schimbe linia #39 din || la &&

Multumesc de sfat, acum merge.

>> while((e!=0) || (i<5));

I think you want to change that to while((e!=0) && (i<5)); I would suggest restructuring your program using functions and std::vector

Thanks for your advice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.