cin
is an istream
object.
It is created in iostream
:
/**
* @name Standard Stream Objects
*
* The <iostream> header declares the eight <em>standard stream
* objects</em>. For other declarations, see
* http://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html
* and the @link iosfwd I/O forward declarations @endlink
*
* They are required by default to cooperate with the global C
* library's @c FILE streams, and to be available during program
* startup and termination. For more information, see the section of the
* manual linked to above.
*/
//@{
extern istream cin; /// Linked to standard input
extern ostream cout; /// Linked to standard output
extern ostream cerr; /// Linked to standard error (unbuffered)
extern ostream clog; /// Linked to standard error (buffered)
#ifdef _GLIBCXX_USE_WCHAR_T
extern wistream wcin; /// Linked to standard input
extern wostream wcout; /// Linked to standard output
extern wostream wcerr; /// Linked to standard error (unbuffered)
extern wostream wclog; /// Linked to standard error (buffered)
#endif
//@}
I tried to create another istream
and use it just like cin - it did not work.
#include<iostream>
int main()
{
std::istream dada;
int foo;
dada>>foo;
std::cout<<foo;
return 0;
}
Because it would not compile.
I'm just looking through the library files to understand how cin
is linked to my shell but another istream
object is not. Can somebody explain?
I am interested in the file where the cin
get's linked to the STDIN
buffer.
Thank you very much.