Namespace code section : NameSpace « Language « C++






Namespace code section

  
#include <iostream>
using namespace std;

namespace first
{
  int x = 5;
}

namespace second
{
  double x = 3.1416;
}

int main () {
  {
    using namespace first;
    cout << x << endl;
  }
  {
    using namespace second;
    cout << x << endl;
  }
  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.Some Namespace OptionsSome Namespace Options
5.A namespace can be nested within anotherA namespace can be nested within another
6.use explicit std:: qualification.use explicit std:: qualification.
7.Using namespace to reference variables
8.Use namespaces to wrap variables
9.Enclosure variables with namespace
10.Defines and tests namespaces.Defines and tests namespaces.