J
John
Hi,
Suppose I have a template clasee
template <class T> A
{
//data ....
T a;
//functions ....
func1(T b);
func2(T b);
func3(T b);
};
In one particular case, say int, func3 is different, so I want to use
template specialization for that case. Do I have to redefine all the
data/functions for int
template <> A<int>
{
//data ....
int a;
//functions ....
func1(int b);
func2(int b);
func3(int b);
}
even though almost everything is identical or can I only specialize the
functions that are different
template <> A<int>
{
func3(int b);
}
and still get the original generic functions/data for everything else?
My understanding is that I have to redefine everything in the
specialization, but I wanted to verify that.
Thanks,
John
Suppose I have a template clasee
template <class T> A
{
//data ....
T a;
//functions ....
func1(T b);
func2(T b);
func3(T b);
};
In one particular case, say int, func3 is different, so I want to use
template specialization for that case. Do I have to redefine all the
data/functions for int
template <> A<int>
{
//data ....
int a;
//functions ....
func1(int b);
func2(int b);
func3(int b);
}
even though almost everything is identical or can I only specialize the
functions that are different
template <> A<int>
{
func3(int b);
}
and still get the original generic functions/data for everything else?
My understanding is that I have to redefine everything in the
specialization, but I wanted to verify that.
Thanks,
John