templace <class T>
class V2d { public: T x,y; }
int main()
{
V2d<int> i(3,3);
V2d<double> d(V2d<double>(i));
}
How to make the statement "V2d<double>(i)" at the 7th line work (to convert a V2d<int> object in an V2d<double> object)?
Posted 30 January 2010 - 11:58 PM
templace <class T>
class V2d { public: T x,y; }
int main()
{
V2d<int> i(3,3);
V2d<double> d(V2d<double>(i));
}
Posted 31 January 2010 - 12:38 AM
template <class T>
class V2d
{
public:
T x, y;
V2d(T x_, T y_): x(x_), y(y_) {}
template <class U>
V2d(const V2d<U> & v): x(v.x), y(v.y) {}
};
0 members, 1 guests, 0 anonymous users