Click here to Skip to main content
15,921,577 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCString memory allocation/corruption? Pin
Jock197914-Sep-04 23:53
Jock197914-Sep-04 23:53 
AnswerRe: CString memory allocation/corruption? Pin
Neville Franks15-Sep-04 2:04
Neville Franks15-Sep-04 2:04 
Generalcombo box value Pin
anuchelvi14-Sep-04 23:04
anuchelvi14-Sep-04 23:04 
GeneralRe: pls help Pin
anuchelvi15-Sep-04 2:23
anuchelvi15-Sep-04 2:23 
GeneralRe: combo box value Pin
David Crow15-Sep-04 3:00
David Crow15-Sep-04 3:00 
GeneralADO, Winsock, Client/Server Pin
Kudakwashe Mafutah14-Sep-04 23:01
Kudakwashe Mafutah14-Sep-04 23:01 
GeneralC++ reference question Pin
Maxime Labelle14-Sep-04 23:00
Maxime Labelle14-Sep-04 23:00 
GeneralRe: C++ reference question Pin
Ryan Binns14-Sep-04 23:18
Ryan Binns14-Sep-04 23:18 
Maxime Labelle wrote:
Somehow, I don't feel it's correct, but I don't know how to make sure about this.

Well, you're right. It's not correct code, and is particularly dangerous. The fact that it didn't crash is purely luck. Basically, you can't take the address (which is what a reference boils down to) of a temporary object, such as the one returned by function(), because the compiler may destroy the object when it hits the next reparse point, in this case the end of the statement. I guess the compiler is recognising that the object is still referred to and is delaying the destruction of it, but I've never seen it happen before, and would strongly recommend against relying on it.

I'm not sure what the standard says about this, but it's certainly not safe code.

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralRe: C++ reference question Pin
Maxime Labelle15-Sep-04 2:00
Maxime Labelle15-Sep-04 2:00 
GeneralRe: C++ reference question Pin
Maxime Labelle15-Sep-04 2:08
Maxime Labelle15-Sep-04 2:08 
GeneralRe: C++ reference question Pin
Mike Beckerleg15-Sep-04 3:21
Mike Beckerleg15-Sep-04 3:21 
GeneralRe: C++ reference question Pin
Taka Muraoka15-Sep-04 4:28
Taka Muraoka15-Sep-04 4:28 
GeneralRe: C++ reference question Pin
Ryan Binns15-Sep-04 16:30
Ryan Binns15-Sep-04 16:30 
GeneralDisplaying unicode chars in textbox - evc++ Pin
soodamani14-Sep-04 22:59
soodamani14-Sep-04 22:59 
QuestionHow To Profile an ISAPI DLL in VC.NET Pin
raed14-Sep-04 22:25
raed14-Sep-04 22:25 
Generalreleasing resources in MFC Pin
nnvidya14-Sep-04 22:21
nnvidya14-Sep-04 22:21 
GeneralRe: releasing resources in MFC Pin
David Crow15-Sep-04 3:05
David Crow15-Sep-04 3:05 
QuestionHow to use VC++ with MsWord.olb to create a table in a *.doc? Pin
杀手无敌14-Sep-04 22:14
杀手无敌14-Sep-04 22:14 
GeneralCFileHeader Pin
fd975014-Sep-04 21:08
professionalfd975014-Sep-04 21:08 
GeneralRe: CFileHeader Pin
Blake Miller15-Sep-04 4:10
Blake Miller15-Sep-04 4:10 
GeneralRe: CFileHeader Pin
fd975015-Sep-04 4:43
professionalfd975015-Sep-04 4:43 
GeneralDateTime control in MFC which takes upto milliseconds Pin
ledallam14-Sep-04 20:25
ledallam14-Sep-04 20:25 
GeneralRe: DateTime control in MFC which takes upto milliseconds Pin
Arsalan Malik14-Sep-04 20:57
Arsalan Malik14-Sep-04 20:57 
GeneralRe: DateTime control in MFC which takes upto milliseconds Pin
ledallam14-Sep-04 21:04
ledallam14-Sep-04 21:04 
GeneralRe: DateTime control in MFC which takes upto milliseconds Pin
Arsalan Malik14-Sep-04 23:09
Arsalan Malik14-Sep-04 23:09 

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.