// myspace.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; namespace A { string str = "hello, andylin!"; void fun1(int nVal) { cout << nVal << endl; } void fun2(string str) { cout << str.c_str() << endl; } } namespace B { string str = "hello, baby!"; void fun1(int nVal) { cout << -nVal << endl; } void fun2(string str) { string strTemp(str.rbegin(), str.rend()); cout << strTemp.c_str() << endl; } } int _tmain(int argc, _TCHAR* argv[]) { A::fun1(123); B::fun1(123); A::fun2(B::str); B::fun2(A::str); return 0; }
C++之Namespace使用源代码
最新推荐文章于 2023-07-24 21:07:14 发布