I have these C++ classes:
class Base
{
protected:
static int method()
{
static int x = 0;
return x++;
}
};
class A : public Base
The variable will be shared - it is per-function - in this case the function it belongs to is Base::method(). However if class Base was a template class you would get one instance of the variable for each instantiation (each unique set of actual template parameters) of class Base template - each instantiation is a new function.