Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Storage classes define the scope, visibility, and lifetime of variables and functions in a C++ program.
autoDefault for local variables. Stored on stack.
staticPersists value between function calls. Allocated once.
externRefers to a global variable defined in another file.
registerHint to store in CPU register (mostly ignored by modern compilers).
mutableAllows modification of a member even in a const object.
void counter() {
static int c = 0; // initialized ONLY once
cout << ++c << " ";
}
// Calling counter() 3 times prints: 1 2 3