1.

Write a function in C++ to read and display the details of all the users, whose membership type is V or ‘M’ from a binary file CLUB.DAT. Assuming the binary file CLUB.DAT is containing objects of class CLUB, which is defined as follows: class CLUB {int Mno; char Mname[20];//member name char Type;//member type :L Life Member // M Monthly Member G Guest public:void Register();//function to enter the content void Display();//function to display all //data members char WhatType(){return Type;}};

Answer»

void DisplayMember()
{
CLUB C;
ifstream fin;
fin.open("CLUB.DAT",ios::binary);
while(fin.read!(char*)&C.sizeof(C)))
{
if((C.WhatType()=='L')||
(C.WhatType!)=='M'))
C.Display();
}
fin.close();
}



Discussion

No Comment Found

Related InterviewSolutions