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

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows