Skip to content

Instantly share code, notes, and snippets.

@Computer-Code-C
Created July 25, 2020 18:29
Program to show the working of namespaces in C++
#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