Defining Class Objects of Different Storage Classes

Class scope includes all its data and function members. It is nested within the file (or another class, function, or even a block) where the class is declared, along with other functions and/or classes. The components of the class can be accessed only when a class object is in scope.

As for variables of any type, class objects (instances, variables) in C++ can be defined as automatic, global, static, or dynamic variables. (See Chapter 6 for a discussion of storage classes.)

For automatic and global (extern or static) variables, the space is allocated implicitly as a result of the object definition. All the previous examples of defining class instances were examples of automatic variables. They ...

Get Core C++ A Software Engineering Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.