Is there any easy way to know what data type is being used? I have a class that I'm using templates with, and I want it to have different functions if it is an integer or a float.
Is there any easy way to know what data type is being used? I have a class that I'm using templates with, and I want it to have different functions if it is an integer or a float.
Hi
I think you need to specialize your whole template class. It´s called explicit instantiation. Search for this if you want to know more about it.
My suggestion i something like this:
[code]
//I suppose you have something like this.
template <class Type>
class Myclass
{
... member,functions etc
};
//You will have to specialize your class by adding this
template <> class MyClass<int>
{
....members,funtions for int etc
};
//and this
template <> class MyClass<float>
{
....members,funtions for float etc
};
[\code]
Hope this helps a bit.
ah, so there's no easy way when you overload every single existing operator? the difference would be atoi versus atol or atof