Click here to Skip to main content
15,892,674 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: reference to const int Pin
Aescleal10-May-12 7:14
Aescleal10-May-12 7:14 
I've used this construct for accessing read only registers on an old data collection card. Despite the fact you couldn't write to them an esteemed colleague of mine decided to try anyway. So after making them const as well as volatile he couldn't any more.

So it's been handy, er, once in my 23 year programming career. In 1994. It's about the only time I've used placement new as well!

As you said, the whole const reference thing is there to make sure you can call things that idiot programmers wrote who didn't understand const. In my experience it's more common when you're calling (very) old C interfaces with pointers. Usually very old C code has an excuse as most C compilers before C90 didn't support const.

Hmmm, wonder if it's worth having a C++FAQ on here, this one comes up at least once a year...

Cheers,

Ash
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 
AnswerRe: use mfc open "*.ppt"--can "use" the ppt Pin
David Crow10-May-12 2:37
David Crow10-May-12 2:37 

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.