Created
July 25, 2020 18:29
Program to show the working of namespaces in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
namespace A | |
{ | |
int x = 5; | |
void printX() | |
{ | |
// function statements goes here | |
cout<<x<<endl; | |
} | |
} | |
namespace B | |
{ | |
int x=10; | |
void printX() | |
{ | |
// function statementsgoes here | |
cout<<x<<endl; | |
} | |
} | |
int main() | |
{ | |
A::printX() ; | |
B::printX(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment