2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by L7Sqr
2

Namespaces are a clarification and encapsulation thing. If you want to associate a section of code with a tag, you can do so with a namespace. For instance

namespace foo {
class Foo { };
}

Now, Foo belongs to the foo namespace. In order to use a Foo object in your code you have to do one of several things:

// Specify the name explicitly
foo::Foo f;

// Bring the type into local scope (just this type)
using foo::Foo;
Foo f;

// Bring in the entirety of the namespace
using namespace foo;

The first method exposes nothing to the local scope but allows you to use that particular item from the foo namespace. The second approach brings in the foo::Foo name to the local scope allowing you to use the Foo name without qualifying where it came from with the scope resolution operator. The final method is an extension of the second except that it brings in all names defined/declared in the namespace to the local scope.
In the case of your question, every type or variable defined within the std namespace will now be visible in the current scope.

Edited by L7Sqr: n/a

Votes + Comments
good post
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.