Click here to Skip to main content
15,887,135 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: else does nto return expected value Pin
Cedric Moonen26-Jan-11 20:35
Cedric Moonen26-Jan-11 20:35 
GeneralRe: else does nto return expected value Pin
Stefan_Lang27-Jan-11 2:20
Stefan_Lang27-Jan-11 2:20 
AnswerRe: else does nto return expected value Pin
Richard MacCutchan26-Jan-11 22:41
mveRichard MacCutchan26-Jan-11 22:41 
QuestionReturning a Reference Pin
Anthony Mushrow26-Jan-11 7:59
professionalAnthony Mushrow26-Jan-11 7:59 
AnswerRe: Returning a Reference Pin
dasblinkenlight26-Jan-11 8:26
dasblinkenlight26-Jan-11 8:26 
AnswerRe: Returning a Reference [modified] Pin
TheGreatAndPowerfulOz26-Jan-11 9:39
TheGreatAndPowerfulOz26-Jan-11 9:39 
GeneralRe: Returning a Reference Pin
Emilio Garavaglia26-Jan-11 22:58
Emilio Garavaglia26-Jan-11 22:58 
GeneralRe: Returning a Reference Pin
Stefan_Lang27-Jan-11 1:57
Stefan_Lang27-Jan-11 1:57 
Just to clear up some of the confusion:

To the compiler, a reference is equivalent to a pointer in everything but the method of dereferencing. It treats the reference as a pointer to a memory location that occupies the contents of some variable.

To the programmer, a reference is equivalent to an alias. Through that reference you can manipulate the contents of another variable without knowing it's orginal name, by using an alternate name. Your method get() effectively returns a temporary alternate alias to your globale variable. You can assign this to a variable of type reference to bclass (bclass&) in order to use that variable as an alias to your global variable, or, like you did, you can just use the temporary alias immediately.

ahmed's suggestion was that you can reassign the alias to another variable, in this case the local variable argh. But it wouldn't work as the address of operator itself is not a reference, and therefore get() is not an l-value. Reassigning a variable of type reference to another variable is not possible.
GeneralRe: Returning a Reference Pin
TheGreatAndPowerfulOz27-Jan-11 8:23
TheGreatAndPowerfulOz27-Jan-11 8:23 
GeneralRe: Returning a Reference Pin
Niklas L26-Jan-11 23:20
Niklas L26-Jan-11 23:20 
GeneralRe: Returning a Reference Pin
Stefan_Lang26-Jan-11 23:57
Stefan_Lang26-Jan-11 23:57 
GeneralRe: Returning a Reference Pin
Niklas L27-Jan-11 1:07
Niklas L27-Jan-11 1:07 
GeneralRe: Returning a Reference Pin
Stefan_Lang27-Jan-11 1:20
Stefan_Lang27-Jan-11 1:20 
GeneralRe: Returning a Reference Pin
TheGreatAndPowerfulOz27-Jan-11 8:02
TheGreatAndPowerfulOz27-Jan-11 8:02 
AnswerRe: Returning a Reference [modified] Pin
Stefan_Lang26-Jan-11 23:12
Stefan_Lang26-Jan-11 23:12 
QuestionAny fast and efficient compress/decompress code? Pin
includeh1026-Jan-11 6:53
includeh1026-Jan-11 6:53 
AnswerRe: Any fast and efficient compress/decompress code? Pin
Anthony Mushrow26-Jan-11 7:41
professionalAnthony Mushrow26-Jan-11 7:41 
AnswerRe: Any fast and efficient compress/decompress code? Pin
Rolf Kristensen26-Jan-11 8:45
Rolf Kristensen26-Jan-11 8:45 
QuestionCapturing stdout from an external program Pin
piul26-Jan-11 3:50
piul26-Jan-11 3:50 
AnswerRe: Capturing stdout from an external program Pin
David Crow26-Jan-11 3:55
David Crow26-Jan-11 3:55 
GeneralRe: Capturing stdout from an external program Pin
piul26-Jan-11 4:43
piul26-Jan-11 4:43 
GeneralRe: Capturing stdout from an external program Pin
David Crow26-Jan-11 5:40
David Crow26-Jan-11 5:40 
QuestionHow to get a CBitmap from a LPDIRECTDRAWSURFACE7 [Solved] Pin
kagelind26-Jan-11 3:01
kagelind26-Jan-11 3:01 
AnswerRe: How to get a CBitmap from a LPDIRECTDRAWSURFACE7 Pin
Code-o-mat26-Jan-11 7:54
Code-o-mat26-Jan-11 7:54 
GeneralRe: How to get a CBitmap from a LPDIRECTDRAWSURFACE7 Pin
kagelind26-Jan-11 23:35
kagelind26-Jan-11 23:35 

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.