C++ Programming/Scope/Examples/Program Namespaces

// Namespaces Program, an example to illustrate the use of namespaces
#include <iostream>

namespace first {
  int first1;
  int x;
}

namespace second {
  int second1;
  int x;
}

namespace first {
  int first2;
}

int main(){
  //first1 = 1;
  first::first1 = 1;
  using namespace first;
  first1 = 1;
  x = 1;
  second::x = 1;
  using namespace second;

  //x = 1;
  first::x = 1;
  second::x = 1;
  first2 = 1;

  //cout << 'X';
  std::cout << 'X';
  using namespace std;
  cout << 'X';
  return 0;
}