can you show me the errors of this code ? #include<conio.h> #include<iostream.h>
ID: 3611843 • Letter: C
Question
can you show me the errors of this code ?#include<conio.h>
#include<iostream.h>
#include <ctype.h>
#include<iomanip.h>
class thucvat
{
protected:
char tenloai[50];
float chieucao;
int soluong;
char mausac[20];
char noict[20];
public:
virtual void nhap();
virtual void xem();
virtual void xemsl(int);
};
//----------------------------------
void thucvat::nhap()
{
cout<<"Name : ";cin.getline(tenloai,50);
cout<<"colour : "; cin.getline(mausac,20);
cout<<"Place : ";cin.getline(noict,20);
cout<<"height : "; cin>>chieucao;
cout<<"quantity : "; cin>>soluong;
}
//---------------------
void thucvat::xem()
{
cout<<endl<<setw(5)<<"tenloai/"
<<setw(8)<<"chieucao/"
<<setw(6)<<"soluong/"
<<setw(6)<<"mausac/"
<<setw(7)<<"noict"<<endl;
cout<<setw(5)<<tenloai<<setw(8)<<chieucao<<setw(6)<<soluong<<setw(6)<<mausac<<setw(7)<<noict;
}
//-------------------------------------------
void thucvat::xemsl(int n)
{
if(soluong<n) thucvat::xem();
}
//-----------------***-------------------------------
class dongvat : public thucvat
{
private:
float trluong;
char loaita[20];
public:
void nhap();
void xem();
void xemsl(int);
};
//-------------------------
void dongvat::nhap()
{
thucvat::nhap();
cin.ignore();
cout<<"Type of food : "; cin.getline(loaita,20);
cout<<"weight : "; cin>>trluong;
}
//----------------------
void dongvat::xem()
{
thucvat::xem();
cout<<endl<<setw(6)<<"loaita/"
<<setw(6)<<"trluong";
cout<<endl<<setw(6)<<loaita<<setw(6)<<trluong;
}
//-----------------------------------
void dongvat::xemsl(int n)
{
if(soluong < n)
{
thucvat::xem();
cout<<endl<<setw(6)<<"loaita/"
<<setw(6)<<"trluong";
cout<<endl<<setw(6)<<loaita<<setw(6)<<trluong;
}
}
//---------------***-----------------------
void main()
{
clrscr();
thucvat *tv[100];
int i=0,n;
int sl;
char chon;
while(1)
{
cout<<"*[D:Dongvat]"<<endl<<"*[T:Thuc Vat]"<<endl
<<"*[E:ESC]"<<endl<<"moi ban chon:";
cin>>chon;
cin.ignore();
chon=toupper(chon);
if(chon!='D' && chon!='T') break;
if(chon=='D') tv[i]=new dongvat;
else if(chon=='T') tv[i]=new thucvat;
tv[i]->nhap();
i=i+1;
}
cout<<endl<<"organism list :";
for(i=0;i<n;i++)
{
cout<<endl<<"organism :"<<i<<endl;
tv[i]->xem();
}
cout<<endl<<"enter quantity find u need : ";cin>>sl;
for(i=0;i<n;i++) tv[i]->xemsl(sl);
getch();
}
Explanation / Answer
please rate - thanks to clear a screen you must use #include system("cls");hope that's a good enough hint to get you goingRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.