[ fromfile: namespaces.xml id: anonymousnamespace ]
A namespace
without a name is an anonymous namespace.
This is similar to a static
global, or file scope identifier.
It is accessible from that point, down to the end of the file.[118]
Example 20.16 shows how anonymous namespaces can eliminate the need for static
globals.
Example 20.16. src/namespace/anonymouse.h
namespace { const int MAXSIZE = 256; } void f1() { int s[MAXSIZE]; }
<include src="src/namespace/anonymouse.h" href="src/namespace/anonymouse.h" role="textbook" id="anonymouseh" mode="cpp"/>
[118] Unless it appears inside another namespace (which the language permits), in which case the scope is further narrowed by the brackets of its enclosing namespace.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |