Overloading by return type

前端 未结 11 1848
我在风中等你
我在风中等你 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

    As stated before, templates are overkill in this case, but it is still an option worth mentioning.

    class My {
    public:
        template T get(int);
    };
    
    template<> int My::get(int);
    template<> char My::get(int);
    

提交回复
热议问题