MENU
Question -

Assuming the class VINTAGE as declared below, write a function in C++ to read the objects of VINTAGE from binary file VINTAGE.DAT and display those vintage vehicles, which are priced between 200000 and 250000.

class VINTAGE {
 int VNO; //Vehicle Number
 char VDesc[10]; //Vehicle Description
 float price;
 public:
 void GET( ) {cin>>VNO;gets(VDesc); cin>>Price;}
 void VIEW( )
 {



Answer -

void Disp( )
 {
 ifstream fin;
 fin.open ("VINTAGE.DAT", ios ::in| ios : : binary);
 vintage V; while (Ifin.eof())
 {
 fin.read ((char*)&V, sizeof(V));
 if (V.ReturnPrice( )> 200000 & &V.ReturnPrice( )<250000)
 V.VIEW ( );
 }
 fin.close ( );
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×