This is a good web page on namespace: http://www.cplusplus.com/doc/tutorial/namespaces.html
namespace myNamespace
{
int a, b;
}
myNamespace::a
myNamespace::b
#include
using namespace std;
namespace first
{
int var = 5;
}
namespace second
{
double var = 3.1416;
}
int main()
{
cout << first::var << endl;
cout << second::var << endl;
return 0;
}
Using the 'using' keyword the namespace can be accessed.
namespace first
{
int x = 5;
}
using first::x;
using namespace first;
cout << x << endl;
both of the above using lines would make the x variable available.
No comments:
Post a Comment