What are static variables designed for? What's the difference between static int and int?
+2
A:
A static member can be referenced without an instance.
See the "Static Members" section here: http://www.cplusplus.com/doc/tutorial/classes2/
Matt
2010-01-03 16:44:34
The question, though, was about static variables, not members.
Michael Krelin - hacker
2010-01-03 16:48:21
It's not clear the OP was making that distinction, even though 'variable' was the term used.
Roger Pate
2010-01-03 17:08:35
@Michael: Which could mean static member variable (it depends what the original question is about and it is not 100% clear).
Martin York
2010-01-03 17:09:44
Martin, yes, it could, but I'd want more evidence before narrowing it down. And just in case - if there were downvotes, then not mine - I only thought the answer deserves comment ;-)
Michael Krelin - hacker
2010-01-03 19:24:54
+3
A:
Static variables are initialized in the data segment (on x86; modify as appropriate for other architectures) instead of on the stack. They persist for the life of the program instead of vaporizing once they go out of scope.
Ignacio Vazquez-Abrams
2010-01-03 16:45:58
It's not clear, but you seem to be mixing two different meanings of static into one definition.
Martin York
2010-01-03 17:07:24