F
Fred Kleinschmidt
I have a template::
template <class V> class Vct {
public:
Vct(V);
};
template <class V>
Vct<V>::Vct( V vin ) {
/*...*/
}
Now I would like to add a copy constructor that
takes as its input any arbitrary instance of a Vct<something>.
For example,
double d = 0.0;
int i = 0;
Vct<double> x ( d );
Vct<int> iy( i );
/* Now I want to make a (double) copy of iy */
Vct<double> z( iy );
/* ... and a (int) copy of x*/
Vct<int> im( x);
Can it be done? How do I define such a constructor
as a template?
template <class V> class Vct {
public:
Vct(V);
};
template <class V>
Vct<V>::Vct( V vin ) {
/*...*/
}
Now I would like to add a copy constructor that
takes as its input any arbitrary instance of a Vct<something>.
For example,
double d = 0.0;
int i = 0;
Vct<double> x ( d );
Vct<int> iy( i );
/* Now I want to make a (double) copy of iy */
Vct<double> z( iy );
/* ... and a (int) copy of x*/
Vct<int> im( x);
Can it be done? How do I define such a constructor
as a template?