How to override a method with template parameter as an argument in C++?

  c++, templates

I have declared a class template which contains a virtual method with template parameter as its argument:

template<typename T>
class BaseClass {
    ...
    virtual void SomeMethod(T arg) = 0;
    ...
};

Now, I want to create a class which is derived from the template and override the method:

class DerivedClass : public BaseClass<int> {
    ...
    void SomeMethod(int arg);
};

But when I want to create an instance of the DerivedClass, compiler complains "cannot declare field … to be of abstract type". Is there any way how to override a method with template parameter as an argument?

Source: Windows Questions C++

LEAVE A COMMENT