1. Home
  2. Computing & Technology
  3. C / C++ / C#

Definition of Namespace

By David Bolton, About.com

Definition: A namespace is a C++ and C# directive that prevents clashes of identifiers.

A developer may use an identifier such as a class name called calculus in an application. The same developer may also add 3rd party libraries to the project. Without namespaces, if a 3rd party library had an identifier called calculus then the compiler or linker would have trouble distinguishing them. By using namespaces- say myapp for the developers library and thirdparty for the thridparty library, the compiler sees the two identifiers as something like myapp.calculus and thirdparty.calculus and there is no ambiguity.

Note

In C++ the syntax for namespaces uses :: not . as in
myapp::calculus

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.