{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Use of Static

Use of Static - Use of Static THE MEANING OF"STATIC Someone...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Use of Static THE MEANING OF "STATIC" Someone asked about the meaning of the term "static" in C++. This particular term is perhaps the most overworked one in the language. It's both a descriptive word and a C++ keyword that is used in various ways. "static" as a descriptive term refers to the lifetime of C++ memory or storage locations. There are several types of storage: - static - dynamic (heap) - auto (stack) A typical storage layout scheme will have the following arrangement, from lowest to highest virtual memory address: text (program code) static (initialized and uninitialized data) heap (large virtual address space gap) stack with the heap and stack growing toward each other. The C++ draft standard does not mandate this arrangement, and this example is only an illustration of one way of doing it. Static storage thus refers to memory locations that persist for the life of the program; global variables are static. Stack storage comes and goes as functions are called ("stack frames"), and heap storage is allocated and deallocated using operators new and delete. Note that usage like: void f() { static int x = 37; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}