programming-examples/c++/Others/A namespace can be nested within another.cpp

21 lines
431 B
C++
Raw Normal View History

2019-11-15 12:59:38 +01:00
A namespace can be nested within another
#include <iostream>
using namespace std;
namespace MyNameSpace1 {
int i;
namespace MyNameSpace2 { // a nested namespace
int j;
}
}
int main()
{
MyNameSpace1::i = 19;
MyNameSpace1::MyNameSpace2::j = 10;
cout << MyNameSpace1::i << " "<< MyNameSpace1::MyNameSpace2::j << "\n";
using namespace MyNameSpace1;
cout << i * MyNameSpace2::j;
return 0;
}