O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.4. Storage Classes

Program variables have a storage class in addition to a data type. Storage classes are important in C++ for several reasons. One, they tell the compiler how to create and release variables and where to place them in the run-time environment (stack, data area, or CPU registers). Two, storage class specifiers affect the initial values and the scope of variables. This section reviews the storage class specifiers auto, static, register, extern, and mutable.

auto

The default storage class specifier auto (short for automatic) allocates memory for variables from the run-time stack. The definition

auto int num; 

for example, compiles in C++, although the keyword auto is optional and seldom used. Automatic definitions appear inside ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required