Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Namespaces in C++

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 64
    Comment on it

    A namespace is  used as an additional information to differentiate similar functions, classes, variables etc. with the same name available in different libraries.

     

    Namespaces are used to identify and differentiate the same entities that we have used in our program.

     

     

    A namespace can be defined with the keyword namespace and with its name.

     

    namespace namespace_name {
       // code declarations
    }

     

     

    #include <iostream>
    using namespace std;
    
    // first name space
    namespace first_space{
       void func(){
          cout << "Inside first_space" << endl;
       }
    }
    // second name space
    namespace second_space{
       void func(){
          cout << "Inside second_space" << endl;
       }
    }
    int main ()
    {
     
       // Calls function from first name space.
       first_space::func();
       
       // Calls function from second name space.
       second_space::func(); 
    
       return 0;
    }

     

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: