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

What is a data structures

  Data structure is a tool in the hands of a programmer for  storing a large number of data items  in the main memory (RAM) of a computer wh...