uj5u.com熱心網友回復:
因為那是const int,雖然你改變了pa里面的值,但是cout<<data<<endl;這句話直接編譯為 cout<<97<<endl;
uj5u.com熱心網友回復:
這時候data的值已經是60了你再輸出data看就知道了
uj5u.com熱心網友回復:
應該是const修飾符的作用吧uj5u.com熱心網友回復:
001E18CD call @__CheckForDebuggerJustMyCode@4 (01E1226h)
const int a = 97;
001E18D2 mov dword ptr [a],61h
int* p = (int*)&a;
001E18D9 lea eax,[a]
001E18DC mov dword ptr [p],eax
*p = 10;
001E18DF mov eax,dword ptr [p]
001E18E2 mov dword ptr [eax],0Ah
cout << a << endl;
001E18E8 mov esi,esp
001E18EA push offset std::endl<char,std::char_traits<char> > (01E1253h)
001E18EF mov edi,esp
001E18F1 push 61h //注意這句話
001E18F3 mov ecx,dword ptr [__imp_std::cout (01EB0A8h)]
001E18F9 call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (01EB09Ch)]
001E18FF cmp edi,esp
001E1901 call __RTC_CheckEsp (01E1230h)
001E1906 mov ecx,eax
001E1908 call dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (01EB0A0h)]
001E190E cmp esi,esp
001E1910 call __RTC_CheckEsp (01E1230h)
當把一個const變數作為函式的引數時候,編譯器往往會直接會把那個變數的值作為字面量傳入函式
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/206152.html
標籤:C++ 語言
上一篇:vs2012中MFC中關于找到單檔案界面激活對話框指標問題
下一篇:按要求輸出 陣列
