I was reading the tutorial on Input/Output with files and I came across two sentences that seemed (to me) to contradict each other.
For ifstream and ofstream classes, ios::in and ios::out are automatically and respectively assumed, even if a mode that does not include them is passed as second argument to the open() member function.
The default value is only applied if the function is called without specifying any value for the mode parameter. If the function is called with any value in that parameter the default mode is overridden, not combined.
To me the first paragraph sounds like it is saying that ios::in and ios::out are true whether the second parameter (the mode) for file open is specified or not. For example:
The first paragraph seems to be saying that ios::in would be true for myfile as well.
However the second paragraph seems to be saying the complete opposite. To me it is saying ios::in and ios::binary are not combined and thus the default value ios::in is overridden. Can someone please help me with this confusion?
I was just looking at this in the Boost Iostream library and there, the first statement is what is implemented. std::ios::in is always appended to the mode flag for an ifstream. Same with ios::out and ofstream. I would assume that is what is specified in the standard.