Restrict C++ Template Parameter to Subclass

前端 未结 7 1427
醉话见心
醉话见心 2020-11-28 22:04

How can I force a template parameter T to be a subclass of a specific class Baseclass? Something like this:

template 

        
相关标签:
7条回答
  • 2020-11-28 22:47

    By calling functions inside your template that exist in the base class.

    If you try and instantiate your template with a type that does not have access to this function, you will receive a compile-time error.

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