In C auto
is a keyword that indicates a variable is local to a block. Since that's the default for block-scoped variables, it's unnecessary and very rarely used (I don't think I've ever seen it use outside of examples in texts that discuss the keyword). I'd be interested if someone could point out a case where the use of auto
was required to get a correct parse or behavior.
However, in the upcoming C++ standard 0x the auto
keyword will be 'hijacked' to support type inference, where they type of a variable can be taken form the type of whatever is initializing it:
auto someVariable = 5; // someVariable will have type int
Type inference is being added mainly to support declaring variables in templates or returned from template functions where types based on a template parameter (or deduced by the compiler when a template is instantiated) can often be quite painful to declare manually.