Nested class as a template parameter of parent class in C++

后端 未结 1 923
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 08:47

I want to implement an algorithm as a class deriving from a pure virtual class representing the kind of problem the particular algorithm solves.

The general interfac

相关标签:
1条回答
  • 2021-01-03 09:11

    I think your problem is the the compiler doesn't know what the inner class looks like until it has defined the outer class and the outer class is defined with the inner class as a template parameter. I'm not 100% sure this can't be made to work. The CRTP is an example similar to this that is known to work.

    Templates can be used to create inheritance hierarchies, but should not be use the in the definition of a hierarchy. If that sounds confusing, it's because it is. Inheritance and template classes don't mix well. Notice that even though CRTP uses inheritance and templates it does not use virtual functions.

    0 讨论(0)
提交回复
热议问题