0
C++
Can somebody explain how static variables are presented in memory. When they are mostly used, and are they alive in memory through the whole main functions or only in block ?
2 Réponses
+ 3
Static variables are alive for the entire time your program exists. The usage depends on the program. Things like: a list of all instances of the class so you can search them, unique id number to assign to the next instance, the root pointer for a link list or tree made up of the instances, etcetera.
0
thanks