命名空间关键字:namespace
namespace A
{
int x = 0;
void f1();
void f2();
}
namespace B
{
int x = 2;
void f1();
void f3();
}
cout << A::x<<endl;
B::f1();
#include<stdlib.h>
#include<iostream>
//using namespace std;
namespace A
{
int x = 1;
void fun()
{
std::cout << "A" << std::endl;
}
}
namespace B
{
int x = 2;
void fun()
{
std::cout << "B" << std::endl;
}
void fun2()
{
std::cout << "BB" << std::endl;
}
}
using namespace B;
int main()
{
std::cout << A::x<<std::endl;
B::fun();
fun2();
std::cout << "hello" <<std:: endl;
system("pause");
return 0;
}