Write a definition for function Economic() in C++ to read each record of a binary file ITEMS.DAT, find and display those items, which costs less than 2500. Assume that the file ITEMS.DAT is created with the help of objects of class ITEMS, which is defined below:
class ITEMS
{
int ID;char GIFT[20]; float Cost;
public:
void Get()
{
cin>>CODE;gets(GIFT);cin>>Cost;
}
void See()
{
cout<<ID<<':'<<GIFT<<':'<<Cost<<endl;
}
float GetCost()
{
return Cost;
}
};
void Economic()
{
ITEMS I;
ifstream fin('ITEMS.DAT',ios::binary);{
while (fin.read((char *)&I,sizeof(I)))
{
if(I.GetCost()<2500)
I.See();
}
}
fin.close();
}