Mega Code Archive

 
Categories / C++ / Language
 

Using namespace to reference variables

#include <iostream> using namespace std; namespace first {   int x = 5;   int y = 10; } namespace second {   double x = 3.1416;   double y = 2.7183; } int main () {   using namespace first;   cout << x << endl;   cout << y << endl;   cout << second::y << endl;   cout << second::x << endl;   return 0; }