I was reading some project code and I found this,here MembersOfLibrary() is a constructor of class MenberOfLibrary
class MembersOfLibrary {
public:
MembersOfLibrary();
~MembersOfLibrary() {}
void addMember();
void removeMember();
unsigned int searchMember(unsigned int MembershipNo);
void searchMember(unsigned char * name);
void displayMember();
private:
Members libMembers;
};
MembersOfLibrary::MembersOfLibrary() {
fstream memberData;
memberData.open("member.txt", ios::in|ios::out);
if(!memberData) {
cout<<"\nNot able to create a file. MAJOR OS ERROR!! \n";
}
memberData.close();
}
I m not able to understand the meaning of --> ios::in|ios::out <-- Please Help out ! Thank You
ios::in
allows input (read operations) from a stream.ios::out
allows output (write operations) to a stream.|
(bitwise OR operator) is used to combine the two ios
flags,ios::in | ios::out
to the constructorstd::fstream
enables both input and output for the stream.Important things to note:
std::ifstream
automatically has the ios::in
flag set.std::ofstream
automatically has the ios::out
flag set.std::fstream
has neither ios::in
or ios::out
automatically