Generic base class with multiple template specialized derived classes

前端 未结 4 1012
梦如初夏
梦如初夏 2021-02-09 02:58

I have a finite amount of classes with the nearly-same implementation, the only different being the underlying type of data they manipulate:

class IntContainer
{         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-09 03:29

    There is simply no way to do what you want.

    The problem is, if this was allowed, the compiler would have to generate as many virtual methods in the base class as there are possible specializations of the template child class (ie. an infinity) which is not possible.

提交回复
热议问题