How to override functions in descendant when ancestor is a template

  ancestor, c++, class, methods, templates

I have a C++ 14 project where my class is based on a template class as follows:

class MyClass: public MyLib::MyBaseClass<MyClass>

In MyBaseClass I have some methods marked virtual, and I am trying to override them in MyClass. Even though their definitions are identical, the compiler thinks they are different and reports error:

error: ‘methodA’ marked ‘override’ but does not override any member
functions

I read in some posts (eg: SO post) that you can mix templates with virtual functions, if the template is at the class level. One answer has 15 upvotes showing this is possible, but there is no explanation offered on how/why this works.

Can someone offer a (simple) explanation?

Source: Windows Questions C++

LEAVE A COMMENT