Syntax

namespace namespace_name  
{
//body of namespace;
}

Syntax of accessing the namespace variable

namespace_name::member_name; 

Sample code

 using namespace std;  
namespace addition
{
int a=5;
int b=5;
int add()
{
return(a+b);
}
}

int main() {
int result;
result=addition::add();
cout<<result;
return 0;
}

Output

 

Categorized in:

C++

Tagged in:

, , , , , , , , , , , ,

Share Article:

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock