Content deleted Content added
Minor grammatical correction. |
→In specific programming languages: Auto means something different now, and was never used much in the original sense |
||
Line 12:
All variables declared within a [[block (programming)|block]] of code are automatic by default. An uninitialized automatic variable has an [[undefined behavior|undefined]] value until it is assigned a valid value of its type.<ref>{{As of|2008|alt=Current}} {{PDFlink|[http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf C standard]|3.61 [[Mebibyte|MiB]]<!-- application/pdf, 3788603 bytes -->}}: section 6.2.4, Storage durations of objects</ref>
Using the storage class <code>register
In C++, the constructor of automatic variables is called when the execution reaches the place of declaration. The destructor is called when it reaches the end of the given program block (program blocks are surrounded by curly brackets). This feature is often used to manage resource allocation and deallocation, like opening and then automatically closing files or freeing up memory. See [[Resource Acquisition Is Initialization]] (RAII). Note, C++11 has a new auto specifier[http://en.cppreference.com/w/cpp/language/auto], which is different. In this case, the variable's type is automatically deduced.
|