// This example shows how the “using” directive works in C++.//// Even if this example use a function, it is the same principle for any// identifiers (variable, namespace, class, type, …).//// Author:// Julien Fontanet <julien.fontanet@isonoe.net>namespace A{ void f() {}}namespace B{ // Imports everything from the namespace A into the namespace B. using namespace A; // Imports only the specified identifier. // // There is no conflict with the previous “using namespace” because the // compiler know that the imported object and the one that is already here // are in fact the same. using A::f;}intmain(){ // Direct call. A::f(); { // Imports everything from the namespace A into this scope. using namespace A; f(); } // Calls the function “f()” defined in the B namespace which has been // imported from the namespace A. B::f(); { // Imports everything from the namespace B into this scope. using namespace B; f(); } // This line will generate an error: there is no such function in the // current scope! f();}