using in namespace oder global?
-
Hi,
macht es irgend einen Unterschied, ob ich using namespace foo; oder using Foo::Bar; in meinem namespace mache oder global?
using namespace std; using Foo::Bar; // Global namespace myNS { using Foo::Bar; using namespace std; // In meinem NS }Falls es einen Unterschied gibt: Was sollte man benutzen?
-
Das using macht das betroffene Symbol nur in dem Scope bekannt, in dem das using steht. Also hier entweder in deinem Namespace oder global. Versuche als Faustregel die usings so lokal wie möglich und so global wie nötig zu machen.
-
und NIE auf Namespace-Ebene (inklusive globalem Namespace) in eiem Header.