Every name defined in a given scope must be unique within that scope. This can be difficult for large complex applications as name collisions become an issue.
Namespaces may be defined at global scope or inside another namespace. They may not be defined inside a function or a class.
The entities defined inside a namespace are called namespace members:

namespace namespace_name
{	...

Names defined in a namespace may be accessed directly by other members of the namespace. Code outside the namespace must indicate the namespace in which the name is defined, e.g.:

	namespace_name::some_member q = namespace_name::some_funtion();

A namespace can be defined in several parts and can therefore be spread out over several files. This means you can use it in the header file declarations and in the associated .cc file.

Using namespace

	std::cout	//:: is the the scope operator and that we want to use the name 'cout' that is
			//defined in the namespace 'std'.

To avoid having to specify the namespace (the library) every time we want to use a method we can use the following:

	using namespace::name

Once the using declaration have been made we can use name directly without refering to its namespace:-

	using std::string;

int main()
	string s;
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.