C++ programming language part- 71 Exercise:
Exercise:
Program 47_10
Look here's a programming code
with main() function which is display the menu, the options are: 1: Query 2:Accept
3: Display and 4: Exit. Modify the class and member
functions. the member data will be * customer Name, * Number of people, *
Package Category, * cost, and tour start date.
void main()
{
char choice;
customer c1;
do
{
cout<<"\n 1: Query 2:Accept
3: Display 4: Exit ";
cout<<"\n\n Type choice: ";
cin>>choice;
if(choice=='1')
{
fstream
fill("customer.txt",ios::in); //ios::app
int
pos,n;
cout<
cin>>n;
pos=(sizeof(customer))*(n-1);
fill.seekg(pos,ios::beg);
fill.read((char*)&c1,sizeof(c1)); //type cast
c1.display
();
fill.close(); }
else if(choice=='2')
{
fstream
fill("customer.txt",ios::app);
c1.accept();
fill.write((char*)&c1,
sizeof(c1)); // type cast
fill.close();
}
else if(choice=='3')
{
fstream
fill("customer.txt",ios::in);
fill.read((char*)&c1,sizeof(c1));
while(fill)
{
c1.display();
fill.read((char*)&c1,sizeof(c1));
}
fill.close();
}
}while(choice!='4');
}