M
Makhno
Hello,
Why does my cast from Vector<class Float> to Vector<float> not work? It
won't compile,
template<class Float> class Vector
{
public:
Vector(Float x1,Float y1,Float z1):x(x1),y(y1),z(z1){}
inline Vector<float> operator() () const;
Float x,y,z;
};
template <class Float> inline Vector<float>
Vector<Float>:perator() () const
{
return Vector<float>((float)x,(float)y,(float)z);
}
int main()
{
Vector<double> pd(5.6,3.4,2.4);
Vector<float> pf=(Vector<float>)pd; /* compiler error here */
}
I'd ideally like to be able to cast a Vector<double> to a Vector<float>.
Why does my cast from Vector<class Float> to Vector<float> not work? It
won't compile,
template<class Float> class Vector
{
public:
Vector(Float x1,Float y1,Float z1):x(x1),y(y1),z(z1){}
inline Vector<float> operator() () const;
Float x,y,z;
};
template <class Float> inline Vector<float>
Vector<Float>:perator() () const
{
return Vector<float>((float)x,(float)y,(float)z);
}
int main()
{
Vector<double> pd(5.6,3.4,2.4);
Vector<float> pf=(Vector<float>)pd; /* compiler error here */
}
I'd ideally like to be able to cast a Vector<double> to a Vector<float>.