Obviously non-static member function can read static data. In fact, that's an important point of having static data - so that instance member functions can read it.
But, is there a good reason (from a OOP design point of view) of having non-static member functions UPDATE the static data variable?
I know of the trivial example of how one might want to keep a counter of how many instances we've created of a particular object. So we can have the constructor update a static int counter. Like so
class Foo
{
static int ctr;
Foo()
{
ctr++;
}
}
But other than this specific example, is there a good general reason of having non-static function update static variables?
Personally I think it seems a bit goofy, but I can't put my finger on what exactly is bothering me.