<< and>> in C++

后端 未结 5 1022
走了就别回头了
走了就别回头了 2020-12-07 03:45

I don\'t quite understand what this means...I\'m just learning C++ from my very very very basic Python experience...and so this may be a very stupid question. My question i

5条回答
  •  执笔经年
    2020-12-07 04:24

    Operators can have different meanings when applied to different types, and C++ allows the developer to overload operators to do just that. It's a powerful technique that should be used cautiously, since it's really easy to make programs unreadable if you overload unjudiciously.

    Therefore >> and << are bit shift operators when the left side is an integer, but input and output operators when the left side is an I/O stream or similar. Read them as arrows pointing which direction the data flows.

提交回复
热议问题