The auto storage class in C++

C++Server Side ProgrammingProgramming

In C, The auto storage class specifier lets you explicitly declare a variable with automatic storage. The auto storage class is the default for variables declared inside a block. A variable x that has automatic storage is deleted when the block in which x was declared exits.

You can only apply the auto storage class specifier to names of variables declared in a block or to names of function parameters. However, these names by default have automatic storage. Therefore the storage class specifier auto is usually redundant in a data declaration.

It was initially carried over to C++ for syntactical compatibility only, although later it got its own meaning, automatic type deduction.

Updated on 30-Jul-2019 22:30:21