Jump to content

insertion "<<" operator, extraction ">>" operator

- - - - -

  • Please log in to reply
2 replies to this topic

#1
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
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.
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
<< 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
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
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