| title | auto Keyword | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||||||
| ms.date | 10/28/2016 | |||||||||||||
| ms.prod | visual-studio-dev14 | |||||||||||||
| ms.reviewer | ||||||||||||||
| ms.suite | ||||||||||||||
| ms.technology |
|
|||||||||||||
| ms.tgt_pltfrm | ||||||||||||||
| ms.topic | language-reference | |||||||||||||
| f1_keywords |
|
|||||||||||||
| dev_langs |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | 744a41c0-2510-4140-a1be-96257e722908 | |||||||||||||
| caps.latest.revision | 14 | |||||||||||||
| author | mikeblome | |||||||||||||
| ms.author | mblome | |||||||||||||
| manager | ghogen | |||||||||||||
| translation.priority.ht |
|
The auto keyword is a declaration specifier. However, the C++ standard defines an original and a revised meaning for this keyword. Before [!INCLUDEcpp_dev10_long], the auto keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with [!INCLUDEcpp_dev10_long], theauto keyword declares a variable whose type is deduced from the initialization expression in its declaration. The /Zc:auto[-] compiler option controls the meaning of the auto keyword.
auto declarator ;
auto declarator initializer; The definition of the auto keyword changes in the C++ programming language, but not in the C programming language.
The following topics describe the auto keyword and the corresponding compiler option:
-
auto describes the new definition of the
autokeyword. -
(NOTINBUILD)auto Keyword (Storage-Class Specifier) describes the original definition of the
autokeyword. -
/Zc:auto (Deduce Variable Type) describes the compiler option that tells the compiler which definition of the
autokeyword to use.