Some Namespace Options : NameSpace « Language « C++






Some Namespace Options

Some Namespace Options
 

#include <iostream>
using namespace std;
namespace MyNameSpace {
  int i;
}
namespace MyNameSpace {
  int j;
}
int main()
{
  MyNameSpace::i = MyNameSpace::j = 10;
  
  cout << MyNameSpace::i * MyNameSpace::j << "\n";   
  
  using namespace MyNameSpace;
  cout << i * j;
  return 0;
}

           
         
  








Related examples in the same category

1.Namespace Demo: define a namespaceNamespace Demo: define a namespace
2.Namespaces are additiveNamespaces are additive
3.Demonstrate a namespaceDemonstrate a namespace
4.A namespace can be nested within anotherA namespace can be nested within another
5.use explicit std:: qualification.use explicit std:: qualification.
6.Using namespace to reference variables
7.Namespace code section
8.Use namespaces to wrap variables
9.Enclosure variables with namespace
10.Defines and tests namespaces.Defines and tests namespaces.