18.2.1. Namespace Definitions
A namespace definition begins with the keyword namespace followed by the namespace name. Following the namespace name is a sequence of declarations and definitions delimited by curly braces. Any declaration that can appear at global scope can be put into a namespace: classes, variables (with their initializations), functions (with their definitions), templates, and other namespaces:
namespace cplusplus_primer { class Sales_data { / * ... * /}; Sales_data operator+(const Sales_data&, const Sales_data&); class Query { /* ... */ }; class Query_base { /* ... */};} // like blocks, namespaces do not end with a semicolon
This code defines a namespace named cplusplus_primer with four members: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access