Whether a file is opened for reading and/or for writing is independent of the corresponding stream
object’s class. The class determines only the default open mode if no second argument is used. This
means that files used only by the class ifstream or the class ofstream can be opened for reading
and writing. The open mode is passed to the corresponding stream buffer class, which opens the file.
However, the operations possible for the object are determined by the stream’s class.