Share on Facebook Share on Twitter Email
Answers.com

Namespace

 
Wikipedia: Namespace

In general, a namespace is an abstract container providing context for the items (names, or technical terms, or words) it holds and allowing disambiguation of homonym items having the same name (residing in different namespaces).

As a rule, names in a namespace cannot have more than one meaning, that is, two or more things cannot share the same name. A namespace is also called a context, as the valid meaning of a name can change depending on what namespace applies. Names in it can represent objects as well as concepts, whether it is a natural or ethnic language, a constructed language, the technical terminology of a profession, a dialect, a sociolect, or an artificial language (e.g., a programming language).

For many programming languages, a namespace is a context for identifiers. In an operating system, an example of namespace is a directory. It contains items which must have unique names. In the Java programming language, items that appear in namespaces have a short (local) name and unique long "qualified" names for use outside the name space. Also, some languages (such as C++) combine namespace and names in a process called name mangling in order to eradicate ambiguity.

Below is an example of a namespace in C++:

namespace Box1{
   int boxSide = 4;
}
 
namespace Box2{
   int boxHeight = 12; 
}
 
int main () {
  cout << Box1::boxSide << endl;    //output 4
  cout << Box2::boxHeight << endl;  //output 12
  return 0;
}

See also


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 
Learn More
IP space (technology)
RDDL (technology)
global namespace (technology)

Which dotnet namespace supports the feature required to create a web based system performance monitor? Read answer...
What is the use of a namespace? Read answer...

Help us answer these
What is the namespace in c?
What is Namespace and Assembly?
How do you use foreign namespaces?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Namespace" Read more