class Base {
public:
staticunsigned typeId() { return s_typeId; }
protected:
staticunsigned s_typeCounter;
staticunsigned s_typeId;
}
unsigned Base::s_typeCounter{0};
unsigned Base::s_typeId{s_typeCounter++};
class A : public Base {
public:
staticunsigned typeId() { return s_typeId; }
private:
staticunsigned s_typeId;
}
unsigned A::s_typeId{s_typeCounter++};
But defining class ids in such a way is a bother. So maybe there's a better way to define class ids considering that ids must be unique among multiple translation units (__COUNTER__ won't do)?