Click here to Skip to main content
15,890,690 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Resizing a WPF Window that is a child to a CView Pin
nadine123458-Oct-11 9:09
nadine123458-Oct-11 9:09 
AnswerRe: Resizing a WPF Window that is a child to a CView Pin
TheGreatAndPowerfulOz18-Oct-11 7:33
TheGreatAndPowerfulOz18-Oct-11 7:33 
QuestionHow do you const your references? Pin
User 5838525-Oct-11 18:35
User 5838525-Oct-11 18:35 
AnswerRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 0:53
Stefan_Lang6-Oct-11 0:53 
GeneralRe: How do you const your references? Pin
TheGreatAndPowerfulOz6-Oct-11 5:55
TheGreatAndPowerfulOz6-Oct-11 5:55 
GeneralRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 6:09
Stefan_Lang6-Oct-11 6:09 
GeneralRe: How do you const your references? Pin
TheGreatAndPowerfulOz6-Oct-11 6:37
TheGreatAndPowerfulOz6-Oct-11 6:37 
GeneralRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 6:48
Stefan_Lang6-Oct-11 6:48 
Not quite. In case of a reference there really is no difference as there is no such thing as a non-const reference. In your example however there would be a difference, but it would only be visible within the code of your function: there, if you defined the parameter const, you could not modify it (locally), whereas if you didn't define it const you could. Of course, since you pass it by value the caller wouldn't notice the difference, basically you gain an additional local variable by not declaring it const.
C++
const Blah* GetBlah1(const Blah*& const b) {
   b = 0; // error: you cannot modify a const reference!
   return b;
}
const Blah* GetBlah2(const Blah*& b) {
   b = 0; // error: you cannot modify a reference, as it's always const!
   return b;
}
const Blah* GetBlah3(const Blah* const b) {
   b = 0; // error: you cannot modify a const pointer
   return b;
}
const Blah* GetBlah4(const Blah* b) {
   b = 0; // ok
   return b;
}
int main() {
   Blah* a = new Blah;
   Blah* b = GetBlah4(a); // this does not modify a
   assert(b==0);
   assert(a!=0);
   delete a;
   return 0;
}

GeneralRe: How do you const your references? Pin
TheGreatAndPowerfulOz6-Oct-11 7:07
TheGreatAndPowerfulOz6-Oct-11 7:07 
GeneralRe: How do you const your references? Pin
Stefan_Lang6-Oct-11 22:07
Stefan_Lang6-Oct-11 22:07 
AnswerRe: How do you const your references? Pin
«_Superman_»6-Oct-11 6:05
professional«_Superman_»6-Oct-11 6:05 
QuestionPostMessage with WPARAM does not work Pin
Vaclav_5-Oct-11 17:43
Vaclav_5-Oct-11 17:43 
AnswerRe: PostMessage with WPARAM does not work Pin
Richard MacCutchan5-Oct-11 21:39
mveRichard MacCutchan5-Oct-11 21:39 
AnswerRe: You can't simulate keyboard input with PostMessage Pin
Software_Developer5-Oct-11 21:50
Software_Developer5-Oct-11 21:50 
AnswerRe: PostMessage with WPARAM does not work Pin
Vaclav_5-Oct-11 23:21
Vaclav_5-Oct-11 23:21 
GeneralRe: PostMessage with WPARAM does not work Pin
enhzflep6-Oct-11 1:10
enhzflep6-Oct-11 1:10 
QuestionHi there all again! This time with an improvement! (and more clear question about C++ ADO) :) Pin
symeramon5-Oct-11 5:21
symeramon5-Oct-11 5:21 
AnswerRe: Hi there all again! This time with an improvement! (and more clear question about C++ ADO) :) Pin
David Crow5-Oct-11 8:10
David Crow5-Oct-11 8:10 
GeneralRe: Hi there all again! This time with an improvement! (and more clear question about C++ ADO) :) Pin
symeramon6-Oct-11 0:47
symeramon6-Oct-11 0:47 
GeneralRe: Hi there all again! This time with an improvement! (and more clear question about C++ ADO) :) Pin
David Crow6-Oct-11 2:55
David Crow6-Oct-11 2:55 
GeneralRe: Hi there all again! This time with an improvement! (and more clear question about C++ ADO) :) Pin
symeramon7-Oct-11 5:33
symeramon7-Oct-11 5:33 
QuestionMFC usage Pin
mysmax5-Oct-11 2:01
mysmax5-Oct-11 2:01 
AnswerRe: MFC usage Pin
Albert Holguin5-Oct-11 2:53
professionalAlbert Holguin5-Oct-11 2:53 
GeneralRe: MFC usage Pin
Stefan_Lang6-Oct-11 1:32
Stefan_Lang6-Oct-11 1:32 
AnswerRe: MFC usage Pin
Software_Developer5-Oct-11 3:11
Software_Developer5-Oct-11 3:11 

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.