在同一个脚本的时候 Main()函数要写在最下面,跟 狗日的 Java 一样
// CTest.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "pch.h"
#include <iostream>
using namespace std;
namespace A {
void func();
int x(100);
void func() {
cout << "我是a命名空间的方法" << endl;
}
}
namespace B {
int x(500);
void func() {
cout << "我是b命名空间的方法,跟a 的方法长得一样" << endl;
}
void fund() {
cout << "是b命名空间的方法,跟A的方法长得不一样" << endl;
}
}
using namespace B;
int main()
{
cout << "Hello World!"<<endl;
A::func();
cout << A::x << endl;
cout << "----------------" << endl;
B::func();
fund();
cout << x << endl;
return 0;
}
// CTe