title: Overloading assignment operator in a class template that can cast to another template type
body: <pre><code>#ifndef NUMBER_HPP
  #define NUMBER_HPP
  
  template &lt;class T&gt;
  class Number
  {
  public:
    Number( T value ) : m_value( value )
    {
    }
  
    T value() const
    {
      return m_value;
    }
  
    void setValue( T value )
    {
      m_value = value;
    }
  
    Number&lt;T&gt;&amp; operator=( T value )
    {
      m_value = value;
    }
  
    //  template &lt;class T2&gt;
    //  Number&lt;T2&gt;&amp; operator=( const Number&lt;T&gt;&amp; number )
    //  {
    //    m_value = number.value();
  
    //    return *this;
    //  }
  
  private:
    T m_value;
  };
  
  typedef Number&lt;int&gt; Integer;
  typedef Number&lt;float&gt; Float;
  typedef Number&lt;double&gt; Double;
  
  #endif // NUMBER_HPP
  </code></pre>
  
  <p>The commented assignment operator overloading is my attempt to do what I want, I thought it might provide a better description than the one above the snippet.</p>
  
  <p>I want to be able to do the following:</p>
  
  <pre><code>Float a(10);
  Integer b(20);
  
  a = b;
  </code></pre>
  
  <p>Where <code>a</code> then would be casted to an <code>int</code> and given the value of <code>b</code>, but still be an instance of class <code>Number</code>.</p>
  
  <p>Is it possible? Can you help me out here?</p>
  
  <p>Thanks in advance.</p>