Suppose I have a template class with a lot of functions and I want to specialize them to change only a few of them and keep the other ones exactly as specified in the base templ
You just have to use two template classes:
template
struct CommonBase
{
void print1() {cout << "Base::print1" << endl;};
void print2() {cout << "Base::print2" << endl;};
};
template
struct Base : public CommonBase
{
};
template<>
struct Base : public CommonBase
{
void print2() {cout << "Base::print2" << endl;};
};
You always use Base
, rather than CommonBase
.