C++ Streams: Sources and Destinations of Data
Consider the following piece of code:
#include <iostream> int main() { std::cout << "Hello World!"; return 0; }
Now, <<
is called an operator. Specifically, <<
inserts
the message into the object std::cout
(the console) and thus is said to be an inserter.
We could write the reverse: something the user types is extracted from the keyboard (into a variable). In most cases, we would need to prompt the user to write something:
#include <iostream> int main() { ... std::cout << "Type your name and press ENTER: "; std::cin >> user_name; return 0; }
So far, we have...