Hi
I was wondering why "<<" in "cout <<" and ">>" in "cin >>" are called insertion and extraction operators respectively. The operator "<<" inserts into what (you should have something in order to insert something into it? Is it display screen which is the object of insertion? Likewise, extraction operator ">>" extracts from what? Display screen?
Please help me with it. Thanks.
2 replies to this topic
#1
Posted 11 October 2011 - 10:23 AM
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)
|
|
|
#2
Posted 11 October 2011 - 11:28 AM
<< and >> are overloaded operators in C++ for use with streams. When used with streams, the operators "extract" and "insert" data from and to those streams. In your question above, 'cin' and 'cout' are the stream objects being used here. 'cout' is an output stream that sends data to the console, and 'cin' is an input stream that reads data from the console.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
#3
Posted 11 October 2011 - 11:35 AM
Basically you are INSERTING into the stdout stream with << and EXTRACTING from stdin stream with >>
Latinamne loqueris?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









