1

In this question that I posted, I received an answer that uses the bit shifting operators << and >>. Can someone explain to me how this works? It appears to be translating, as if piping the value from one thing into the other all on one line in a series of left bit shift or right bit shift.

Please realize that I'm new to C++. I haven't studied it in 20 years, and I'm learning it again.

Community
  • 1
  • 1
Volomike
  • 23,743
  • 21
  • 113
  • 209

2 Answers2

2

Those are overloaded operators they're not actually doing any bitshifting, your example seems to be using ostream's << operator which inserts data into the output stream.

Matthew Mcveigh
  • 5,695
  • 22
  • 22
1

here are some other topics on operation overloading Operator overloading Basically, any operator can be re-purposed for the use on other types, including non primitive types. In the example you listed, we would really have to know what types the << operator was being used on. For streams, the << and >> operators have been overloaded to write content to the stream or read content from the stream.

Community
  • 1
  • 1
Rusty Weber
  • 1,541
  • 1
  • 19
  • 32