Skip to content

Latest commit

 

History

History
60 lines (52 loc) · 1.85 KB

File metadata and controls

60 lines (52 loc) · 1.85 KB
title auto Keyword | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-language
ms.tgt_pltfrm
ms.topic language-reference
f1_keywords
auto
auto_cpp
dev_langs
C++
helpviewer_keywords
automatic storage class, auto keyword
auto keyword
ms.assetid 744a41c0-2510-4140-a1be-96257e722908
caps.latest.revision 14
author mikeblome
ms.author mblome
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

auto Keyword

The auto keyword is a declaration specifier. However, the C++ standard defines an original and a revised meaning for this keyword. Before Visual C++ 2010, the auto keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with Visual C++ 2010, the auto 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.

Syntax

auto declarator ;  
auto declarator initializer;  

Remarks

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 auto keyword.

  • /Zc:auto (Deduce Variable Type) describes the compiler option that tells the compiler which definition of the auto keyword to use.

See Also

Keywords