it is possible to change return type when override a virtual function in C++?

后端 未结 6 1395
醉梦人生
醉梦人生 2020-12-16 03:34

I encounter a problems about override virtual functions, in fact,it is about hessian (a web service protocol).

it has a base class Object, and some derived classes :

6条回答
  •  自闭症患者
    2020-12-16 04:19

    Unfortunately you can't overload functions in C++ by return value. What you could do, if you have the appropriate some_convert_function in place for all types you need it for would be to create free a template function that looks something like this:

    template
    std::string toString(T const& t)
    {
      return some_convert_function(t);
    }
    

提交回复
热议问题