Sunday, February 25, 2018

C++ : Namespace concept with example program

#include <iostream>
using namespace std;
namespace first
{
int x = 17;
int y = 10;
}
namespace second
{
double x = 3.1416;
double y = 19.4635;
}
int main() {
using first::x; // Fill the gap
using second::y; // Fill the gap
cin >> x ;
cin >> y ;
cout << x << endl;
cout << y << endl;
cout << first::y << endl;
cout << second::x << endl;
return 0;
}

Thanks
Happy Computing !

No comments:

Post a Comment

Python script to show Laptop Battery Percentage

Source:  https://www.geeksforgeeks.org/python-script-to-show-laptop-battery-percentage/ # python script showing battery details  import psut...