Namespaces

A large program may have thousands of functions, and it can become difficult to tell them apart. No matter how well you name them, they will get mixed up. This is, of course, not just a problem with programs; the phone book of even a small town would be impossible to use if people did not have surnames. Programmers often use naming conventions to keep functions separate (for example, stack operations would be called stack_pop(), stack_push(), and so on) but are not always consistent. Namespaces are a way of grouping functions and variables together, in much the same way that families share the same surname.

The Global Namespace

A global declaration is visible throughout a program. Although they are not necessarily evil, global variables ...

Get C++ By Example: UnderC Learning Edition 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.