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

Sacred Thought

28 April 2024 Today I am going to explain verse 31 - 38 chapter two for you all. There is no opportunity better than a righteous war (सत्य औ...