I was curious, what is the scope of variables declared inside a class constructor which are not data members of that class?
For example, if a constructor needs an iterating int i
, will this variable be destroyed after the constructor finishes, or is it then global for the program?
In this sense a constructor is like any other function - any variable declared inside has usual scope limitations and they all surely go out of scope and get destroyed once constructor is finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With