Let us say I have the following class -
class X {
int y;
};
Lot of other classes start using X.
Now, I want to make X a template class so that I can write,
template<class T>
class X {
T y;
};
How to minimize the impact on the client?
One way I can think of is, define the template class with a default
argument and with a new name,
template<class T = int>
class X1 {
T y;
};
and then do a typedef,
typedef X1<> X;
So the older clients can continue using the name X and they will get
the desired behavior.
The newer clients can use X1<float> etc.
Is this a good approach and are there any better ones?
Thanx,
gg