On Wednesday, October 30, 2013 12:27:49 AM UTC+1, Alf P. Steinbach wrote:
>
> This is a main difference between a using DIRECTIVE (which you employed)
> and a using DECLARATION (above). The directive only directs lookup. The
> declaration acts more like a declaration. :-)
As for how this "direction" works: It's like the names are injected
into the closest namespace level that contains both, the context in
which you are writing the directive and the namespace you are naming
in the directive. So, for example:
int i;
namespace foo {
namespace bar {
int i;
}
namespace baz {
using namespace bar; // puts the names from ::foo::bar
// "temporarily" into ::foo because
// foo is the "closest" namespace that
// contains both bar and baz.
void func() {i=23;} // i refers to ::foo::bar::i, it is
// found when lookup reaches the foo
// namespace.
}
void another() {i=42;} // i refers to ::i.
}
By "temporarily" I tried to refer to the scope in which the using
directive is "active".
HTH,
SG