// File: namespace2.cpp // // Simple use of namespace directive #include using namespace std ; namespace MySpace { int i = 7, j = 8 ; } namespace DS9 { int i = 17, j = 18 ; } main() { // using namespace directive tells the compiler to // pretend the declarations in MySpace were global. using namespace MySpace ; cout << "MySpace::i = " << i << endl ; cout << "MySpace::j = " << j << endl ; cout << "DS9::i = " << DS9::i << endl ; cout << endl ; // :: operator not affected //local variable hides MySpace::i int i = 1001 ; cout << "i = " << i << endl ; cout << "MySpace::i = " << MySpace::i << endl ; }