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;
}
daianahoney 0 Newbie Poster
Clinton Portis 211 Practically a Posting Shark
mrnutty 761 Senior Poster
daianahoney 0 Newbie Poster
daianahoney 0 Newbie Poster
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.