3.6. Namespaces

An earlier section (“Storage Classes” on page 124) explains scope rules for variables in C++. Program variables may be:

  1. Local (declared inside functions without static and exist in local stack frames)

  2. External static with file scope (declared outside functions with static)

  3. Global with program scope (declared outside functions without static)

  4. Internal static (declared inside functions with static and exist in the data area)

With program scope (3), separately compiled modules require access to function names, structures, and objects, often placed in global namespace. Global namespace includes all names from global declarations; that is, declarations appearing outside of function definitions. What is the proper way to deal with global ...

Get Navigating C++ and Object-Oriented Design 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.