0

I can't grasp the idea that what << and >> are doing.

I read that they are bitwise shifting operators, but what they do in cout/cin?

Like we say

strong text std:: cout << variable 1 << variable2 ..... << variableN;

what does it mean to join cout with variables through multiple << operator.

Will be highly appreciative of any guidance in this regard.

  • They become the stream operators, formatting objects for output. See https://en.cppreference.com/w/cpp/io/basic_istream/operator_gtgt and https://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt – user4581301 Jul 29 '21 at 21:55
  • Possible duplicate https://stackoverflow.com/questions/4854248/why-are-bitwise-shifts-and-used-for-cout-and-cin The answers have quotes from the designer of C++ that explain his thinking. For example https://stackoverflow.com/a/4854374/2193968 – Jerry Jeremiah Jul 29 '21 at 21:55
  • 1
    see chosen answer to "Override and Overload in C++" https://stackoverflow.com/a/429236/2785528 – 2785528 Jul 29 '21 at 22:04
  • See [What are the basic rules and idioms for operator overloading?](https://stackoverflow.com/questions/4421706/what-are-the-basic-rules-and-idioms-for-operator-overloading) for help on how to write your own streaming operators for your classes. – user4581301 Jul 29 '21 at 22:07

0 Answers0