EXPLORATION 52

image

Names and Namespaces

Nearly every name in the standard library begins with std::, and only names in the standard library are permitted to start with std::. For your own names, you can define other prefixes, which is a good idea and an excellent way to avoid name collisions. Libraries and large programs in particular benefit from proper partitioning and naming. However, templates and names have some complications, and this Exploration helps clarify the issues.

Namespaces

The name std is an example of a namespace, which is a C++ term for a named scope. A namespace is a way to keep names organized. When you see a name that begins ...

Get Exploring C++ 11, Second 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.