title: it is possible to change return type when override a virtual function in C++?
body: <p>I encounter a problems about override virtual functions, in fact,it is about hessian (a web service protocol).</p>
  
  <p>it has a base class Object, and some derived classes : Long,Int,String,...,all derived classes has a no-virtual function "value"</p>
  
  <pre><code>   class Object  
     {  
       ...    
     };  
  
  
     class Long :public Object  
     {  
         ...  
     public:  
         typedef long long  basic_type;  
         basic_type value(){return value_;}  
     private:  
         basic_type value_;  
         ...  
     };  
  
  
     class Int :public Object  
     {  
        ...  
     public:  
         typedef int basic_type;  
         basic_type value(){return value_;}  
     private:   
         basic_type value_;  
         ...  
     };  
  </code></pre>
  
  <p>now I want to add a function ,say, toString ,which can convert Object to a string:</p>
  
  <pre><code>Object *obj  = ...
  cout&lt;&lt;obj-&gt;toString();
  </code></pre>
  
  <p>if I can change the value function to   virtual ,I only need to write a toString function in Object, else, I need to write a virtual function toString, and to override this functions in all derived classes.</p>
  
  <p>for example</p>
  
  <pre><code>   class Object  
     {  
         virtual Type value(); // It seemed that I can't write a function like this,because the Type is different for different derived classes  
  
  
         std::string toString()  
         {  
             some_convert_function(value());  
         }  
  
     };  
  </code></pre>
  
  <p>but I can't write a virtual value function because of return value can't be override.  </p>
  
  <p>is there any good solution for this issue?  </p>
  
  <p>Thanks  </p>