Templatized Virtual function

后端 未结 4 1258
渐次进展
渐次进展 2020-12-05 21:40

We know that C++ doesn\'t allow templated virtual function in a class. Anyone understands why such restriction?

4条回答
  •  鱼传尺愫
    2020-12-05 22:25

    How would you construct the vtable? Theoretically you could have an infinite number of versions of your templated member and the compiler wouldn't know what they might be when it creates the vtable.

提交回复
热议问题