Sydney said:
Isn't a local static variable assigned to a memory area that is
neither on the stack and not part of the normal heap? That's
how the local static variable can be used to remember state
within a function between calls to the function. Also, since C
never had anything like namespaces, global static variables
where one way to control name collisions: that is one of the
reasons for developing C++ and other OO languages in the next
generation. SCF
Please don't toppost. I fixed this one.
C doesn't have heaps, stacks, etc. Those are things specific to
the implementation, which must do the appropriate incantations to
magically satisfy the C standard on the available hardware. The
point is that static variables retain their values even when the
scope in which they are declared is left. They are also not
visible outside the compilation unit.
C does have namespaces. Certain names are reserved for the
implementation, especially those beginning with a '_'. In
addition the namespaces for struct and enum tags are separate from
user namespace. What C doesn't do is enforce those restrictions.
C++ is NOT a next generation, it is a separate (and different)
language, with some superficial similarities to C and much higher
complexity. Opinions as to whether it is an improvement vary.