This is probably a better question for comp.lang.c++. As far as I can tell,
all that is stated by the specification is that in c++, declaring a class
variable as static causes all instances of the class to share that variable.
It doesn’t seem to make any distinction between a variable declared in class
or method scope. So, that would mean that the behaviour you are observing
Kevin Hykin <email@example.com> wrote:
Info: running QNX RTP, compiling with qcc.
If a variable is declared static inside a method of a class, would you
expect it to be local static to the method or class static? The reason I am
asking is because a static variable in a method of a class that I was using
behaved like a class static variable. When I declared multiple instances of
the class both of them were using the same copy of the static variable. Is
this what I should expect?
“You’re bound to be unhappy if you optimize everything” - Donald Knuth