Chapter 20. Scope and Storage Class

Identifiers have scope, objects have a storage class, and variables have both. In this chapter, we discuss the difference between declarations and definitions, and how to determine the scope of identifiers and the storage class of objects.

20.1

Declarations and Definitions

464

20.2

Identifier Scope

465

20.3

Storage Class

470

20.4

Namespaces

473

Declarations and Definitions

Any identifier must be declared or defined before it is used.

Declaring a name means telling the compiler what type to associate with that name. The location of the declaration determines its scope. Scope is a region of code where an identifier can be used.

Defining an object, or variable, means allocating space and (optionally) assigning an initial value. ...

Get An Introduction to Design Patterns in C++ with Qt 4 now with O’Reilly online learning.

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