#include "stdafx.h"
#include <iostream>
using std::cout; //使用命名空间std中的cout
using std::endl;
namespace mycode //在自己的mycode命名空间中定义foo()函数
{
void foo()
{
cout<<"foo"<<endl;
}
}
void foo() //定义foo()函数
{
cout<<"another foo"<<endl;
}
int main()
{
mycode::foo(); //调用mycode命名空间中的foo()函数
foo();
system("pause");
}
此代码运行结果为: