Jump to content

C++ Programming/Programming Languages/C++/Code/Keywords/auto

From Wikibooks, open books for an open world

The auto keyword is used to have the compiler infer the type of the variable which follows it from the RHS or from its declaration.

Example
[edit | edit source]
auto a = 3;      // int
auto b = 4.5;    // double
auto p = &a;     // pointer