Why should I include iostream and ostream separately?

I noticed that many people include iostream and ostream in C ++ programs separately, for example:

#include <iostream>
#include <ostream>
int main()
{
}

Why would anyone do this? Since iostream inherits from ostream, it should include everything in it, right? Is there any strange reason? What about simple (std :: cout) code?

+5
source share
2 answers

stringstream iostream, <iostream>. <iostream> iostream, cout, cerr, cin clog, iostreams (, ). #include .

. ++ , , , <iostream> <ostream>, <istream>. , , <iosfwd>. , #include <iostream> istream ostream. , , , .

+6

iostream istream ostream ( ++ 0x, gnu libstd++ ), ostream

:

fstream fstream ( ),

sstream ( )

iostream / (, cin, cout,...)

iosfwd - , .

+3

All Articles