/* */ Click to Join Live Class with Shankar sir Call 9798158723

What is namespace scope ?


A namespace is declaration region where we can define a group of variable, classes, object and function. the main purpose of a namespace is to localize the name of identifiers having the same name to avoid collisions.

All namespace are identified by different name and we can have any number of namespace.Namespaces are regions in a program logically separated from the rest. They are necessary if you want more than one function with the same name.

Q.) Example of Namespace Variables in C++ .
    
    #include < iostream>  
using namespace std;  
namespace First{  
   void sayHello(){  
      cout << "Hello First Namespace" << endl;  
   }  
}  
namespace Second{  
   void sayHello(){  
      cout << "Hello Second Namespace" << endl;  
   }  
}  
using namespace First;  
int main () {  
   sayHello();  
   return 0;  
}  

Output
Hello First Namespace