Archived

This topic is now archived and is closed to further replies.

popcorn

cin/cout

Recommended Posts

This is probably a pretty stupid question but how come you don''t have to create instances of the istream/ostream objects before you use cin/cout. I think it maybe because they are already defined for you in the iostream header file but i am not sure. Anyone want to clear this up for me? How about them apples?

Share this post


Link to post
Share on other sites
Ummm... Does it really matter?

oh and it ''How ''bout them Knicks''

My funnies:
"My mom was a ventriloquist and she always was throwing her voice. For ten years I thought the dog was telling me to kill my father."
and:
"The longest word in the english language is the one that follows the phrase, ''''And now a word from our sponsor''''."

Share this post


Link to post
Share on other sites

By default, standard output provided by cout, cerr and clog is directed to the screen although this may vary depending on the environment:

http://www.cplusplus.com/ref/iostream/cout.html

By default, standard input is read from the keyboard, thus cin is generally used to get information directly from the user:

http://www.cplusplus.com/ref/iostream/cin.html

Share this post


Link to post
Share on other sites
of course it matters betrayer_of_code, things like this bug me for some reason.

thanks for the links vohaul. i managed to find the answer to my question.
quote:

Standard objects
Within the iostream library, declared in the header file there are certain objects that are used to perform input and output operations on the standard input and output devices.
They are divided in two sets: narrow-oriented objects, which are the popular cin, cout, cerr and clog and wide-oriented iostream objects, declared as wcin, wcout, wcerr and wclog.



I guess the above statement from the cplusplus website answers my question.

Does anyone know if the cplusplus website is still regularly updated with articles and suchlike. The STL part in the reference section never seems to get finished.

How about them apples?

[edited by - popcorn on December 24, 2002 10:44:06 PM]

[edited by - popcorn on December 24, 2002 10:51:50 PM]

Share this post


Link to post
Share on other sites
Yes, cin, cout, and cerr are all global objects (well, global in the std namespace) declared in <iostream>. They are instantiated before main() is called.


Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites