Why are bitwise shifts (<< and>>) used for cout and cin?

后端 未结 13 1679
眼角桃花
眼角桃花 2020-12-02 16:16

Question is in the title really; I\'m sure there is something logical, but for now I\'m stumped!

13条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 17:04

    >> and << are just operators and you can implement your own >> and << for your classes.

    I suppose "somebody" selected them because: a) they are similar to shell file operations and b) to reuse existing operators because there are no need to create new ones

提交回复
热议问题