Automatic variable: Difference between revisions

Content deleted Content added
C, C++: (Minimally) incorporate mention to RAII in sentence.
Adding local short description: "Local variable in computer programming", overriding Wikidata description "stack-allocated variable that is automatically deallocated upon leaving the scope in which it was declared"
 
Line 1:
{{Short description|Local variable in computer programming}}
{{About|Automatic variables|the C++ keyword {{Cpp|auto}} used for [[type inference]]|C++11#Type inference}}
In [[computer programming]], an '''automatic variable''' is a local [[Variable (programming)|variable]] which is allocated and deallocated automatically when program flow enters and leaves the variable's scope. The [[Scope (computer science)|scope]] is the lexical context, particularly the function or block in which a variable is defined. Local data is typically (in most languages) invisible outside the function or lexical context where it is defined. Local data is also invisible and inaccessible to a ''called'' function,<ref group="note">unless it is a [[nested function]], which itself is ''defined'' along that local data</ref> but is not deallocated, coming back in scope as the [[execution thread]] returns to the caller.