Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: what's means? Pin
wangafei10-May-12 16:47
wangafei10-May-12 16:47 
Questionreference to const int Pin
Aabid9-May-12 21:16
Aabid9-May-12 21:16 
AnswerRe: reference to const int Pin
ThatsAlok9-May-12 21:18
ThatsAlok9-May-12 21:18 
GeneralRe: reference to const int Pin
Aabid9-May-12 21:25
Aabid9-May-12 21:25 
AnswerRe: reference to const int Pin
Richard MacCutchan9-May-12 22:32
mveRichard MacCutchan9-May-12 22:32 
AnswerRe: reference to const int Pin
Code-o-mat9-May-12 22:35
Code-o-mat9-May-12 22:35 
GeneralRe: reference to const int Pin
Aescleal10-May-12 5:06
Aescleal10-May-12 5:06 
GeneralRe: reference to const int Pin
Code-o-mat10-May-12 6:00
Code-o-mat10-May-12 6:00 
Aescleal wrote:
The reason for that is that the compiler can't assume that i is fixed any more (you've told it that something somewhere could modify it) so there's a real variable behind it.
I know. Smile | :) As far as i know this basically means "don't keep in a register", so the compiler will do its best to keep the memory up-to-date.


Aescleal wrote:
You're still not allowed to modify it through i though! This sort of trick is really handy for overlaying C++ objects on ranges of addresses for memory mapped devices.
I think you shouldn't be able to do it, since usually things are declared as const for a reason, if you need to change them then don't make them const. But of course, there are those nasty situations when doing that can and will come in handy, like when you are using some 3rd party code you are not allowed (or simply don't want) to modify and try to call a method through a const pointer about which you know it does not change the object (like some simple Get method) and realize that the coder who created it kinda forgot to make the method const. Altrough this still might be dangerous because the method's implementation might change in the future and after the next update of the 3rd party library/codebase it borks everything...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<

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 
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 

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.