Namespaces allow us to
combine entities like classes, objects and
functions under a name.
It Introduces every name from the std
namespace into the current scope block.
The keyword using (using
namespace std;) is
used to introduce a name from a namespace
into the current area. In this example,
there are two global variables with the same
name: x.
One is defined within the namespace first
and the other one in second.
#include <iostream.h>
using namespace std;
namespace one
{
int x = 5;
}
namespace two
{
float x = 3.1416;
}
int main () {
cout << one::x << endl;
cout << two::x << endl;
return 0;
} |