What is the semantics of the line "using namespace std;"?

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.

commented: good post +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.