If class inherits base class with static variable member, Will be their only one member that shared with all classes that inheritances.
I have few kinds inherits classes, and many instance of every one of them.
I want that every one of the inherits classes will have a separate static member, that shared with all of its instances.
How can it be done?
thank you, and sorry about my poor English.
edit:
class a{
static int var;};
class b::a{};
class c::a{};
Now, I want that all instances of b will have same var, and all instances of c will have same var , but the var of b will be different from the var of c.
I’m sorry again about my English, if you can correct me, please do it.
You can work aroud that using CRTP :
AClassandAnotherClassboth have avariablestatic variable (of typeMember), but the first one is a static variable fromYourBaseClass<AClass>and the other is fromYourBaseClass<AnotherClass>, which are two different classes.YourBaseBaseClassis optional, but you need it if you want to manipulateAClassandAnotherClassusing aYourBaseBaseClass*pointer (you cannot have aYourBaseClass*pointer, becauseYourBaseClassis not a class).And remember to define those static variables.