Creating Namespaces - C++ Statement

C++ examples for Statement:namespace

Description

Creating Namespaces

Demo Code

#include <iostream> 

using namespace std;
namespace Player 
{ 
        void PrintName() 
        { //from ww  w. ja v  a 2s .c o m
                std::cout << "My name is Bruce!" << endl; 
        } 
} 
  
namespace Vehicle 
{ 
        void PrintName() 
        { 
                std::cout << "I am a car!" << endl; 
        } 
} 
  
using namespace Player; 
  
int main(int argc, char *argv [])
{ 
        PrintName(); 
  
        Vehicle::PrintName(); 
  
        return 0; 
}

Result


Related Tutorials