How to convert between different classes in C++?
<p>I have a question related to conversion of different classes as the following code script shows:</p>

<pre><code>template&lt;typename E&gt;
class Coordinate 
{
public:
    E x_;
    E y_;
    Coordinate(E x, E y):x_(x),y_(y) {};
    Coordinate():x_(0),y_(0) {};
    ~Coordinate() {};
};

typedef vector&lt;Coordinate&lt;float&gt; &gt; Cordfloat;
typedef vector&lt;Coordinate&lt;double&gt; &gt; Corddouble;




int main()
{
    Corddouble myarray;
    Coordinate&lt;float&gt; value(1.2,1.3);
    // myarray.push_back(value);  // failed!!!
    // Option 1
    Coordinate&lt;double&gt; temp;
    temp.x_ = static_cast&lt;double&gt;(value.x_);
    temp.y_ = static_cast&lt;double&gt;(value.y_);
    myarray.push_back(temp);
    // Option 2
    // myarray.push_back(static_cast&lt;Coordinate&lt;double&gt; &gt;(value)); // failed!!!
    // Option 3
    // myarray.push_back(dynamic_cast&lt;Coordinate&lt;double&gt; &gt;(value)); // failed!!!

    return 0;
}
</code></pre>

<p>In the above codes I try three means to do the job. Only the first method works. It seems I cannot use <code>static_cast</code> and <code>dynamic_cast</code> for conversion directly. I was wondering whether there are other means of performing the conversion task. </p>
