Overloading by return type

前端 未结 11 1846
我在风中等你
我在风中等你 2020-11-22 07:07

I read few questions here on SO about this topic which seems yet confusing to me. I\'ve just begun to learn C++ and I haven\'t studied templates yet or operator overloading

11条回答
  •  时光取名叫无心
    2020-11-22 07:46

    You can think this way:

    You have:

      int get(int);
      char get(int);
    

    And, it is not mandatory to collect the return value of the function while invoking.

    Now, You invoke

      get(10);  -> there is an ambiguity here which function to invoke. 
    

    So, No meaning if overloading is allowed based on the return type.

提交回复
热议问题