Template specialisation for templated base class
Hi all,
I have a template that I want to specialise for a specific class and it's sub classes i.e.
Code:
template <typename T>
class MyTemplate
{
public:
static void DoStuff(void)
{
cout << "generic template" << endl;
}
};
class Base
{
};
class Derived : public Base
{
};
template <>
class MyTemplate<Base>
{
public:
static void DoStuff(void)
{
cout << "base template" << endl;
}
};
int main()
{
MyTemplate<int>::DoStuff(); // OK - prints "generic template"
MyTemplate<Base>::DoStuff(); // OK - prints "base template"
MyTemplate<Derived>::DoStuff(); // BAH! - prints "generic template"
}
anyone have any ideas? If I can solve this than I'll worry about the next problem (Base is also a template!!)