So in the last lecture we went over the concept called scope and he said the scope of declaration is
the part of the program for which the variable or identifier is accessible.
So today I want to talk about lifetime which is sort of a similar concept to scope and the lifetime
a variable is the time period in which the variable has valid memory.
So the lifetime of x rays here is just the amount of time that phunk is active.
So when x is defined initialized the memory is for x is valid.
And as soon as phunk is finished say in line 18:3 here then X is automatically destroyed so the memory
is not valid anymore.
Ducey can't use X anymore after func there's just the memory is just not there for it anymore.
So if an X was declared outside of any function.
So it was a global variable then the lifetime of x would be how long the program runs itself.
So just it would be the entire run of the program so interestingly if you think about it if you had
a variable in the main function then its lifetime would also be the entire run of the program.
Since Maine is the very first function that is called in your program it will be the last function to
exit so however its scope is only the main function and remember.
So we'll be using this fact to our advantage in our games and we'll talk about lifetime a little bit
more later.