C++ static CString 变量在成员函数与全局函数中的不同表现

来源:互联网 发布:python hex 编辑:程序博客网 时间:2024/05/12 10:24
class Test{ public:Test(void); virtual ~Test(void); CString GetStaticA(); CString GetStaticB();};Test::Test(void){}Test::~Test(void){}CString Test::GetStaticA(){ static CString myTTT; myTTT = "123456"; return myTTT ;}CString Test::GetStaticB(){ CString myTTT; myTTT = "123456"; return myTTT ;}//Test 为全局对象Test myTest;//全局函数__declspec(dllexport) char *  testDllStaticA(){ //这种情况下,返回值是一长串"哈哈哈哈" return myTest.GetStaticA().GetBuffer(0);}__declspec(dllexport) char * WINAPI testDllStaticB(){ static CString testB; testB = myTest.GetStaticB(); //这种情况下,返回值是"123456" return testB .GetBuffer(0);}

                                             
0 0
原创粉丝点击