3.7 STORAGE CLASSES

C++ supports the following keywords as storage class specifier:

  • auto
  • register
  • static
  • extern

3.7.1 auto

We can declare local variables as auto (storage class). Such variables will be called as automatic variables. The default storage class of local variables of every function is auto (it stands for automatic). These variables come into existence with the function in which they are defined. They vanish as soon as that function terminates. There is nothing special about this storage class. Normally, we do not specify it explicitly.

3.7.2 Keyword register

Keyword register is a qualifier. For example,

register int i;

A variable required again and again is declared as of type register. Declaration is a request to the compiler ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.