Sarthaks Test
0 votes
15 views
in Computer by (15 points)
edited by

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;
}
};

Please log in or register to answer this question.

1 Answer

0 votes
by (24.3k points)

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();
}

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...