Content deleted Content added
m →C, C++ |
m tags and general fixes, removed stub tag using AWB (8842) |
||
Line 5:
==In specific programming languages==
=== C, C++ ===
(Called ''automatic'' variables.)
Line 14 ⟶ 15:
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 [[RAII]].
===
(Called ''local variables''.)
Similar to C and C++, but there is no <code>auto</code> or <code>register</code> keyword. However, the Java compiler will not allow the usage of a not-explicitly-initialized local variable and will give a compilation error (unlike C and C++ where the compiler will usually only give a warning). The Java standard demands that every local variable must be explicitly initialized before being used.<ref>{{cite web | url=http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.12.5 | title=4.12.5 Initial Values of Variables | publisher=Sun Microsystems | accessdate=2008-10-17}}</ref> This differs from instance variables, which are implicitly initialized with default values (which are <tt>0</tt> for numbers and <tt>null</tt> for objects).
===
(Called ''lexical'', ''my'' or ''private'' variables.)
Line 40 ⟶ 41:
[[Category:Memory management]]
[[Category:Variable (computer programming)]]
[[es:Asignación automática de memoria]]
|