// Reproduced from page 847 of 'The C++ Programming Language' (3ed). // Shows 'using directives' and 'using declarations' by examples. This variant is compilable. #include #include namespace X { int i = 10, j = 11, k = 12; } int k; // Global variable void f1(){ // Illustrates using directives int i = 0; using namespace X; // A using directive makes i, j, and k from X accessible i++; // local i j++; // X::j ::k++; // global k X::k++; // X::k } void f2(){ // Illustrates using declarations int i = 0; using X::j; using X::k; // hides global k i++; // local i j++; // X::j k++; // X::k } int main(){ f1(); f2(); }