Need some help about template member function specialization as following code;
class Base
{
public:
template <int> void MyFunc();
};
class Object : public Base
{
public:
//template <int> void MyFunc(); // with this works !!!
template <> void MyFunc<3>()
{
}
};
Thanks !!!
CodePudding user response:
You can't.
The reason is that when the compiler sees the declaration of Object, it doesn't know anything about Base's template functions. So it can't generate a specialization of MyFunc for Object.
The only way to make this work is to declare the specialization of MyFunc in the Base class.
Member function templates are not inherited.