C++ namespace 語法
#include "stdafx.h"
#include<stdlib.h>
#include<iostream>
using namespace std;
namespace A
{
int x = 5;
void fun()
{
cout << "A" << endl;
}
}
namespace B
{
int x = 2;
void fun()
{
cout << "B" << endl;
}
}
int main(void)
{
cout << A::x << endl;
B::fun();
? ? return 0;
}
最后的 B::fun();
難道不用加cout嗎?
2017-12-02
你定義的函數里面已經有輸出了,所以不用再定義。