C++ multiple operator overloads for the same operator

前端 未结 3 1870
星月不相逢
星月不相逢 2021-02-14 04:14

I know I can answer this question easily for myself by generatin the code and see if it compiles. But since I couldn\'t find a similar question, I thought it\'s knowledge worth

3条回答
  •  借酒劲吻你
    2021-02-14 04:41

    Yes.


    These operator functions are just ordinary functions with the special names operator@. There's no restriction that they cannot be overloaded. In fact, the << operator used by iostream is an operator with multiple overloads.

提交回复
热议问题