Creating an interface for an abstract class template in C++

前端 未结 5 565
暗喜
暗喜 2020-12-08 05:10

I have the code as below. I have a abstract template class Foo and two subclasses (Foo1 and Foo2) which derive from instantiations of the template. I wish to use pointers in

5条回答
  •  天涯浪人
    2020-12-08 05:33

    I don't think you can get what you want. Think of this if you were to implement your suggestion: if you have a pointer to an IFoo instance and you call functionB(), what type parameter should you give it? The underlying problem is that Foo1::functionB and Foo2::functionB have different signatures and do different things.

提交回复
热议问题