65,186
社区成员




#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const int i=3;
const int *pa=&i;
int *pb=const_cast<int*>(pa);
*pb=4;
cout<<"pa="<<pa<<" pb="<<pb<<" &i="<<&i<<endl;
cout<<"*pb="<<*pb<<" "<<"i="<<i<<" "<<"*pa="<<*pa<<endl;
return 0;
}
int i=3;
int *pa=&i;
int *pb=pa;
*pb=4;
cout<<"pa="<<pa<<" pb="<<pb<<" &i="<<&i<<endl;
cout<<"*pb="<<*pb<<" "<<"i="<<i<<" "<<"*pa="<<*pa<<endl;
return 0;
12: cout<<"*pb="<<*pb<<" "<<"i="<<i<<" "<<"*pa="<<*pa<<endl;
0040161F push offset @ILT+200(std::endl) (004010cd)
00401624 mov eax,dword ptr [ebp-8]
00401627 mov ecx,dword ptr [eax]
00401629 push ecx
0040162A push offset string "*pa=" (0046c030)
0040162F push offset string " " (0046c02c)
00401634 mov edx,dword ptr [ebp-4] //这里从栈上i的地址读取值
00401637 push edx
00401638 push offset string "i=" (0046c028)
0040163D push offset string " " (0046c024)
00401642 mov eax,dword ptr [ebp-0Ch]
00401645 mov ecx,dword ptr [eax]
00401647 push ecx
00401648 push offset string "*pb=" (0046c01c)
0040164D push offset std::cout (004777e0)
00401652 call @ILT+655(std::operator<<) (00401294)