To understand C++, you have to understand that C++ has many of the most powerful tools to build abstractions. cout
is nothing but a stream
. So, it is very acceptable to mimic the concept of stream.
For example,
std::cout << "hey"; // '<<' is something like the direction of the `data`
throws things in the stream with the same syntax and conventions, infact there is only one syntax for all types.
Also,
std::cin >> number;
extracts the next value of the type specified by number
and put it in number
.
It just make sense when you think about streams in C++. You can see this in most modern C++ libraries, for example with Boost
you can do this:
boost::filesystem::path mypath;
....
mypath = mypath/filename;
The division operator is replaced with '/
' or '\
' depending on the system you are targeting :)