MENU
Question -

Assuming the class ANTIQUE as declared below, write a function in C++ to read the objects of Antique from binary file ANTIQUE. DAT and display those antique items, which are priced between 10000 and 15000.

class ANTIQUE
 {
 int ANO;
 char Aname [10] ;
 float price;
 public :
 void BUY() {cin>>ANO;gets(Aname); cin>> price;}
 void SHOW ( )
 {



Answer -

void Disp( )
 {
 ifstream fin;
 fin.open ("ANTIQUE.DAT", ios:: in |ios : : out | ios : : binary);
 Antique A;
 while (!fin.eof( ))
 { -
 fin.read ((char*) &A, sizeof(A));
 if (A.GetPrice ( )> 10000 & A.GetPrice( )<15000)
 A.SHOW( );
 }
 fin.close( ) ;
 }

Comment(S)

Show all Coment

Leave a Comment

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