lallous wrote:
Hello,
Why is the static variable inside a member function static for all instances
and not static for the current instance of the object?
It would not comply with the general static variable concept.
All variables marked with the keyword static indicate variables which
lifetime is as long as the lifetime of the program. Hence they exist
even when no object of that type was created only you cannot access them
outside of their visibility scope.
So no object can have its own static variable copy and all such
variables are shared by all entities that can access given function. It
is identical as in the case of static data member.
Regards,
Janusz
Only are not accessible in the case when they are object functions
How would it differ then from an object data member?