I encounter a problems about override virtual functions, actually,it's about hessian (an internet service protocol).
it features a base class Object, plus some derived classes : Lengthy,Int,String,...,all derived classes includes a no-virtual function "value"
class Object class Lengthy :public Object lengthy lengthy fundamental_type fundamental_type value() private: fundamental_type value_ ... class Int :public Object fundamental_type fundamental_type value() private: fundamental_type value_ ...
now I wish to give a function ,say, toString ,which could convert Resist a string:
Object *obj = ... cout<<obj->toString()
basically can alter the worthiness function to virtual ,I only have to write a toString function in Object, else, I have to write an online function toString, and also to override this functions in most derived classes.
class Object appeared which i can't write a function such as this,simply because the kind differs for various derived classes std::string toString()
however i can't write an online value function due to return value can not be override.
can there be worthwhile solution with this problem?