Why we should use ios::in or ios::out when we use ifstream or ofstream respectivly?
It is obvious that we want to input data when we use ifstream.
Printable View
Why we should use ios::in or ios::out when we use ifstream or ofstream respectivly?
It is obvious that we want to input data when we use ifstream.
You need them for the fstream, which is not quite sure what it's going to do until you tell it ios::in or ios::out.
But I've seen many places where it came with ifstream or ofstream.
std::ifstream and std::ofstream automatically have std::ios::in and std::ios:: out respectively. std::fstream requires you to specify them though.
OK, Why we should use ofstream or ifstream when fstream exists?