Monday, July 14, 2008

Namespace

1. The definition of namespace does not have to be continuous and can even span different program text files, which could help us to organize the library into interfaces and implementations.

2. Scope operators can also be used to refer to members of the global namespace. Global namespace does not have a name. ::name_in_the_globalspace

3. A nested namespace is a nested scope within the namespace that contains it. And during name resolution, nested namespace behave similarly to nested blocks. An entity declared in an enclosing namespace is hidden by an entity of the same name declared in a nested namespace. Silmiarly, an entity declared in a namespace is hidden by an entity declared in local scope.

4. Unnamed namespace is used to declare an entity locale to a file and never spans multiple text files. It is not necessary to use scope operator to refer to members of unnamed namespaces. In C, a global static is invisible outside of the file in which it is declared.

5. Namespace aliases
namespace IBM_1 = International_Business_Machines
namespace IBM_2 = International_Business_Machines

6. A name introduced by a using declaration has these characteristics:
6.1. It must be unique in its scope
6.2. It hides the same name introduced by a declaration in an enclosing scope
6.3. It is hidden by a declaration of the same name in a nested scope

No comments: