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: ...
Get C++ Primer, Fifth 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.