August 2012
Intermediate to advanced
976 pages
30h 17m
English
As we saw in § 7.1.3 (p. 261), we cannot copy or assign objects of the IO types:
ofstream out1, out2;out1 = out2; // error: cannot assign stream objectsofstream print(ofstream); // error: can't initialize the ofstream parameterout2 = print(out2); // error: cannot copy stream objects
Because we can’t copy the IO types, we cannot have a parameter or return type that is one of the stream types (§ 6.2.1, p. 209). Functions that do IO typically pass and return the stream through references. Reading or writing an IO object changes its state, so the reference must not be const.
Read now
Unlock full access