+ 1

Iostream

what are input/output streams? what happens if we don't include iostream?

13th Feb 2017, 1:25 PM
Mich
Mich - avatar
3 Answers
+ 3
cin is an istream(input stream) class object tied to standard input (i.e it is required to take data from the user from the console) cout is an ostream(output stream) class object tied to standard output (i.e it is required to display data from the programmer to the user through the console) and if you do not include iostream every instance of cin,cout or cerr will get flagged as an error.
13th Feb 2017, 2:20 PM
Prabal Titus
Prabal Titus - avatar
+ 1
It is simply a way to access the command line in a console window (or "DOS" box if you come from the Windows world) for both input and output. The "streaming" operators (<< and >>) are just overloaded operators included by the appropriate header files (istream.h, ostream.h). Note you can use the same (streaming) technique to write/read to/from files as well. If you don't include iostream.h (which includes istream.h and ostream.h), the compiler will complain about "unresolved externals" since it will not find any definitions for these functions (including 'cout' and 'cin').
13th Feb 2017, 2:35 PM
Ettienne Gilbert
Ettienne Gilbert - avatar
+ 1
Thank you
13th Feb 2017, 2:39 PM
Mich
Mich - avatar