I know there is a related question: Static variables in static method in base class and inheritance
But I am wondering if this is the same for datamembers?
suppose I have a class:
class A
{
protected:
static int NUMBER;
private:
static int OTHERNUMBER;
};
class B : public A
{
};
Will B have another instance than A of NUMBER?
Will B have another instance than A of OTHERNUMBER?
No, and no. Declaring a static variable in any class scope only declares a single variable, and no extra copies of it will appear in any other scope.