August 2012
Intermediate to advanced
976 pages
30h 17m
English
Referring to namespace members as namespace_name::member_name is admittedly cumbersome, especially if the namespace name is long. Fortunately, there are ways to make it easier to use namespace members. Our programs have used one of these ways, using declarations (§ 3.1, p. 82). The others, namespace aliases and using directives, will be described in this section.
A namespace alias can be used to associate a shorter synonym with a namespace name. For example, a long namespace name such as
namespace cplusplus_primer { /* ... */ };
can be associated with a shorter synonym as follows:
namespace primer = cplusplus_primer;
A namespace alias declaration begins with the keyword namespace, followed ...
Read now
Unlock full access