Saved Bookmarks
| 1. |
Write a function in C++ to search and display details, whose destination is “Chandigarh”from binary file “Flight.Dat”. Assuming the binary file is containing the objects of the following class: class FLIGHT{ int Fno; // Flight Numberchar From[20]; // Flight Starting Pointchar To[20]; // Flight Destinationpublic:char * GetFrom ( ); { return from; }char * GetTo( ); { return To; }void input() { cin>>Fno>>; gets(From); get(To); }void show( ) { cout<<Fno<< “:”<<From << “:” <<To<<endl; }}; |
|
Answer» void Dispdetails() { ifstream fin(“Flight.Dat”); Flight F; while (fin) { fin.read((char*)&F,sizeof(F)) if (strcmp(F.GetTo(),”Chandigarh”)) F.show(); } } |
|