问题
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 counter
s 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