If is is a normal function outside the class, then any local variables in it area declared once.
- If the function is inside the class, then any local variables are declared by the number of times the class is instantiated.
No, the variables created in a function ( class member or standard non-member function ) are created on the stack, they only exist while the function is running. You need recursion to get multiple instances of a function executing at once.
'c' is created when an instance is created, 'a' only gets created when the constructor runs, same as 'b' only exists when DoStuff is called.
a & b are destroyed when their creating function goes out of scope ( ends/returns )