Home Is this description of "static variable" on Wikipedia right?
Reply: 0

Is this description of "static variable" on Wikipedia right?

Zebrafish Published in 2018-01-10 14:02:19Z

The opening paragraph of Wikipedia on "static variable" here:

static variable

makes me think that I might have the wrong concept of an "object" in the general sense. Specifically the bit that says automatic variables are allocated on the stack, and "objects" are dynamically allocated on the heap.

a static variable is a variable that has been allocated "statically", meaning that its lifetime (or "extent") is the entire run of the program. This is in contrast to shorter-lived automatic variables, whose storage is stack allocated and deallocated on the call stack; and in contrast to objects, whose storage is dynamically allocated and deallocated in heap memory.

I use mostly (C++), and an "object" has nothing to do with how or where it's allocated. You can create as an automatic variable, permanently on the stack, or dynamically on the heap.

Is this description right for most other languages or in a general sense?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.392033 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO