In this example why do I need CRTP?

浪尽此生 提交于 2019-12-13 10:26:02

问题


See Object counter example here: Why it just does not inherit from non-template class counter. Why counter should be template?

template <typename T>
struct counter

回答1:


Specializations will give you different counters for different types.
Note that those counters are static data members, thus shared among all instances of the given specialization.



来源:https://stackoverflow.com/questions/37530699/in-this-example-why-do-i-need-crtp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!