C++命名空间的用法

//#include <stdafx.h>
#include <cstdlib>
#include
<iostream>
using namespace std;

namespace anamespace
{
int x;
void SetX(int xvalue)
{

x
= xvalue;
cout
<<x<<endl;
}
};

namespace anothernamespace
{

int x;
void SetX(int xvalue)
{
x
= xvalue;
cout
<<x<<endl;

}
};

int main()
{
anamespace::SetX(
5);
anothernamespace::SetX(
10);
return 0;

}

posted @ 2011-05-16 17:12  hnrainll  阅读(429)  评论(0编辑  收藏  举报