EDIT: This is just another case “silly & uninteresting mistake”. You’ve been warned 🙂
Here’s something that’s been keeping me up at night. Maybe someone with higher C++ knowledge can find how to get this to work:
template<class T>
class Base
{
virtual void Method ( T* arg ) = 0;
};
class Child : public Base<MyType>
{
void Method ( MyType* arg ) { /*blah*/ };
};
This doesn’t compile (at least on VS2008 it doesn’t) because it can’t match the two Methods together.
Currently we get around it by using a BaseType instead of MyType in the Method declaration and then cast BaseType to MyType in the Child implementation of the Method (We still need the MyType as a template for other stuff inside the base class).
Still it would be nice to be able to use the templated type directly.
EDIT:
Thanks guys it seems that fixing other errors (that were listed after) made it all work.
I did have template<class T> instead of template<T> in my original code as well as the Method listed as public.
It shows that I should have waited longer before posting. I apologize for that.
Here is full example that compiles and works fine :