Wednesday, 23 January 2019

What are C++ storage classes

What are C++ storage classes?

Answer:

auto

register

static

extern

auto:

the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that block.

register:

a type of auto variable. a suggestion to the compiler to use a CPU register for performance.

static:

a variable that is known only in the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins execution.

extern:

a static variable whose definition and placement is determined when all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined.

No comments:

Post a Comment