이번 내용은 local variable의
duration lifetime에 관한 내용으로 생략한다
Q2 What’s the difference between a variable’s scope, duration, and lifetime? By default, what kind of scope and duration do local variables have (and what do those mean)?
A variable’s scope determines where the variable is accessible. Duration defines the rules that govern when a variable is created and destroyed. A variable’s lifetime is the actual time between its creation and destruction.
Local variables have block scope, which means they can be accessed inside the block in which they are defined.
Local variables have automatic duration, which means they are created at the point of definition, and destroyed at the end of the block in which they are defined.