样例:
#include <iostream> using namespace std; namespace Jack { int age; void sayHello() { cout << "hello, I'm Jack" << endl; } } namespace Johns { int age = 20; void sayHello() { cout << "hello, I'm Johns" << endl; } } int main() { Jack::age = 10; cout << Jack::age << endl; Jack::sayHello(); cout << Johns::age << endl; using Johns::sayHello; sayHello(); return 0; }