23 Local Static in C++

Lifetime refers to the actual existence time of a variable, i.e., how long the variable stays in memory before it is deleted. Scope is the range in which we can access this variable.

Static local variable allows us to declare a variable whose lifetime is the entire duration of the program, but its scope is limited to the function in which it is declared.

Variables created with static are placed in the heap, with a default value of 0.