Click here to Skip to main content
15,913,487 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: reference to const int Pin
Code-o-mat10-May-12 6:00
Code-o-mat10-May-12 6:00 
GeneralRe: reference to const int Pin
Aescleal10-May-12 7:14
Aescleal10-May-12 7:14 
GeneralRe: reference to const int Pin
Code-o-mat10-May-12 8:05
Code-o-mat10-May-12 8:05 
GeneralRe: reference to const int Pin
jschell10-May-12 9:19
jschell10-May-12 9:19 
GeneralRe: reference to const int Pin
Code-o-mat10-May-12 9:22
Code-o-mat10-May-12 9:22 
GeneralRe: reference to const int Pin
Aescleal11-May-12 2:17
Aescleal11-May-12 2:17 
GeneralRe: reference to const int Pin
jschell11-May-12 13:21
jschell11-May-12 13:21 
AnswerRe: reference to const int Pin
CPallini9-May-12 22:53
mveCPallini9-May-12 22:53 
I don't know if (by the C++ specifications) that is the correct behaviour, however both the compiler provided by Visual Studio 2005 and g++ 4.4.3 gave me the same results you obtained.
Apparently (even with optimizations turned off) the compiler replaces each occurrence of i with the literal value 10, making all the changes you perform on the corrensponding memeory address irrelevant.
Compare the code generated for j and i in the cout lines:

j
ASM
cout << "j= " << j << endl;
0041143A  mov         eax,dword ptr [__imp_std::endl (4182B4h)]
0041143F  push        eax
00411440  mov         ecx,dword ptr [j] <=============== MEMORY ADDRESS
00411443  mov         edx,dword ptr [ecx]
00411445  push        edx
00411446  push        offset string "j= " (41570Ch)
0041144B  mov         eax,dword ptr [__imp_std::cout (4182BCh)]
00411450  push        eax
00411451  call        std::operator<<<std::char_traits<char> > (4110F0h)
00411456  add         esp,8
00411459  mov         ecx,eax
0041145B  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (4182C0h)]
00411461  mov         ecx,eax
00411463  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (4182C4h)]


i
ASM
cout << "i= " << i << endl;
00411469  mov         eax,dword ptr [__imp_std::endl (4182B4h)]
0041146E  push        eax
0041146F  push        0Ah  <================= LITERAL (10)
00411471  push        offset string "i= " (415710h)
00411476  mov         ecx,dword ptr [__imp_std::cout (4182BCh)]
0041147C  push        ecx
0041147D  call        std::operator<<<std::char_traits<char> > (4110F0h)
00411482  add         esp,8
00411485  mov         ecx,eax
00411487  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (4182C0h)]
0041148D  mov         ecx,eax
0041148F  call        dword ptr [__imp_std::basic_ostream<char,std::char_traits<char> >::operator<< (4182C4h)]

Veni, vidi, vici.

AnswerRe: reference to const int - more Pin
Richard MacCutchan10-May-12 0:32
mveRichard MacCutchan10-May-12 0:32 
GeneralRe: reference to const int - more Pin
Aabid10-May-12 1:06
Aabid10-May-12 1:06 
GeneralRe: reference to const int - more Pin
Richard MacCutchan10-May-12 1:12
mveRichard MacCutchan10-May-12 1:12 
GeneralRe: reference to const int - more Pin
Aabid10-May-12 1:36
Aabid10-May-12 1:36 
GeneralRe: reference to const int - more Pin
Richard MacCutchan10-May-12 2:23
mveRichard MacCutchan10-May-12 2:23 
AnswerRe: reference to const int Pin
Aescleal10-May-12 4:56
Aescleal10-May-12 4:56 
AnswerRe: reference to const int Pin
jschell10-May-12 9:23
jschell10-May-12 9:23 
Questionuse mfc open "*.ppt"--can "use" the ppt Pin
wangafei9-May-12 21:07
wangafei9-May-12 21:07 
AnswerRe: use mfc open "*.ppt"--can "use" the ppt Pin
ThatsAlok9-May-12 21:08
ThatsAlok9-May-12 21:08 
GeneralRe: use mfc open "*.ppt"--can "use" the ppt Pin
wangafei9-May-12 21:13
wangafei9-May-12 21:13 
AnswerRe: use mfc open "*.ppt"--can "use" the ppt Pin
David Crow10-May-12 2:37
David Crow10-May-12 2:37 
AnswerRe: use mfc open "*.ppt"--can "use" the ppt Pin
Malli_S10-May-12 0:55
Malli_S10-May-12 0:55 
Questioncreating a dialog in non mfc application Pin
Rajeev.Goutham9-May-12 21:01
Rajeev.Goutham9-May-12 21:01 
AnswerRe: creating a dialog in non mfc application Pin
ThatsAlok9-May-12 21:11
ThatsAlok9-May-12 21:11 
GeneralRe: creating a dialog in non mfc application Pin
wangafei9-May-12 21:15
wangafei9-May-12 21:15 
GeneralRe: creating a dialog in non mfc application Pin
Rajeev.Goutham9-May-12 21:22
Rajeev.Goutham9-May-12 21:22 
AnswerRe: creating a dialog in non mfc application Pin
ThatsAlok9-May-12 22:57
ThatsAlok9-May-12 22:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.