Given the code below, the compiler is showing a message pointing that error: templates may not be ‘virtual’
. Does anyone have a suggestion on how to solve the bug?<
If you really need to make this method virtual, consider making CBar<>
polymorphic and pass a base type in which isn't templated.
EDIT: something like this:
// non-templated base class
class BarBase
{
// common methods go here..
};
template
class CBar : public BarBase
{
// implement methods from BarBase ...
};
template < class FOO_TYPE>
class CFoo{
public:
...
// now we take the base type, and this method does not need to be a template
virtual void doSomething( BarBase const* ptrBar );
...
virtual ~CFoo();
protected:
MyClass < FOO_TYPE > * m_pClass;
};
template < class FOO_TYPE >
void CFoo::doSomething( BarBase const* ptrBar ){
..
}