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

From Wikibooks, open books for an open world
Jump to navigation Jump to search

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]
auto a = 3;      // int
auto b = 4.5;    // double
auto p = &a;     // pointer