namespace

C/C++ Reference

namespace
Syntax:
  namespace name {
  declaration-list;
  }

The namespace keyword allows you to create a new scope. The name is optional, and can be omitted to create an unnamed namespace. Once you create a namespace, you'll have to refer to it explicitly or use the using keyword.

Example code:
   namespace CartoonNameSpace {
     int HomersAge;
     void incrementHomersAge() {
       HomersAge++;
     }
   }
   int main() {
     ...
     CartoonNameSpace::HomersAge = 39;
     CartoonNameSpace::incrementHomersAge();
     cout << CartoonNameSpace::HomersAge << endl;
     ...
   }            
Related topics: