1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Several iostream related i(header file)s are available. Depending on
the situation at hand, the following header files should be used:
itemization(
iti(iosfwd): sources should include this header file if only a declaration
of the stream classes is required. For example, if a function defines a
reference parameter to an tt(ostream) then the compiler does not need to know
exactly what an tt(ostream) is. When declaring such a function
the tt(ostream) class merely needs to be be declared. One cannot use
verb(class std::ostream; // erroneous declaration
void someFunction(std::ostream &str);)
but, instead, one should use:
verb(#include <iosfwd> // correctly declares class ostream
void someFunction(std::ostream &str);)
ithi(ios): sources should include this header file when using
types and facilites (like tt(ios::off_type), see below) defined in the
tt(ios) class.
ithi(streambuf): sources should include this header file when using
tt(streambuf) or ti(filebuf) classes. See sections ref(STREAMBUF) and
ref(FILEBUF).
ithi(istream): sources should include this preprocessor directive when
using the class tt(istream) or when using classes that do both input and
output. See section ref(ISTREAM).
ithi(ostream): sources should include this header file when using the class
ti(ostream) class or when using classes that do both input and output. See
section ref(OSTREAM).
ithi(iostream): sources should include this header file when using the
global stream objects (like ti(cin) and ti(cout)) and also when defining a
stream capable of reading and writing from the same device (see also
section ref(IOSTREAMBUF)).
ithi(fstream): sources should include this header file when using the file
stream classes. See sections ref(OFSTREAM), ref(IFSTREAM), and ref(FSTREAM).
ithi(sstream): sources should include this header file when using the
string stream classes. See sections ref(OSTRINGSTREAM) and ref(ISTRINGSTREAM).
ithi(iomanip): sources should include this header file when using
parameterized manipulators. See section ref(IOFORMAT).
)
|