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

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...