As the book says (Exploring C++: The Programmer's Introduction to C++):
The istream header declares input operators (>>), and ostream declares output operators(<<).
I can perfectly run the code without adding #include <ostream>
:
#include <iostream>using namespace std;int main(){ cout << "hello world"<< endl; return 0;}
But, in book's example like:
#include <iostream>#include <ostream> //why?using namespace std;int main(){ cout << "hello world"<< endl; return 0;}
So, iostream
, ostream
and istream
are header files right?
If ostream
is not necessary (iostream
does the job) why does the author include it in the example? Or why does the ostream
header file still exist?
Note: In Bruce Eckel's Vol 1 book (which is published in 2000) there is nothing about ostream
or istream
. Only one header file which is iostream
.