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 ?

19th Nov 2018, 10:02 PM
Nikola
Nikola - avatar
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.
24th Nov 2018, 3:31 AM
John Wells
John Wells - avatar
0
thanks
24th Nov 2018, 7:23 AM
Nikola
Nikola - avatar