Click here to Skip to main content
15,911,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: InvertRgn Pin
Mark Salsbery27-Nov-07 10:50
Mark Salsbery27-Nov-07 10:50 
QuestionLoad dll's Pin
Anthony Mushrow26-Nov-07 8:41
professionalAnthony Mushrow26-Nov-07 8:41 
AnswerRe: Load dll's Pin
Mark Salsbery26-Nov-07 8:44
Mark Salsbery26-Nov-07 8:44 
GeneralRe: Load dll's Pin
Anthony Mushrow26-Nov-07 8:49
professionalAnthony Mushrow26-Nov-07 8:49 
Questionnumber of open files limit Pin
Joezer BH26-Nov-07 8:08
professionalJoezer BH26-Nov-07 8:08 
AnswerRe: number of open files limit Pin
Mark Salsbery26-Nov-07 8:30
Mark Salsbery26-Nov-07 8:30 
AnswerRe: number of open files limit Pin
Stephen Hewitt26-Nov-07 13:08
Stephen Hewitt26-Nov-07 13:08 
QuestionTemplate function returning a variable of type T Pin
racette26-Nov-07 7:22
racette26-Nov-07 7:22 
I have a template function that returns a variable of type T.

Here is the signature of that function:

T GetData();

When everything goes well, GetData() perform some tasks then returns a valid variable of type T.

Sometimes, for different reasons, the function cannot return a valid variable of type T. In these cases, I would have like to return NULL to notify the calling function that GetData() could not 'get' any 'data'.

Here is my problem:

I cannot return NULL since type T could be a int, a CString, a MyCar, a pointer or anything.

So I declare a local variable of type T inside the GetData() function, load it with stuff when possible, and return this local variable at the end of the function.

The problem is now that sometimes, my software crash with an exception telling me that I'm using a local variable that has not been initialized.

Also, I cannot just 'initialize' it as I would with any other kind of variables since this one is of type T, it could be anything.

Anyone has an idea how to get around this problem?

Thanks!


Benjamin Racette
CAE software developer
racette@cae.com

AnswerRe: Template function returning a variable of type T Pin
Cedric Moonen26-Nov-07 7:28
Cedric Moonen26-Nov-07 7:28 
GeneralRe: Template function returning a variable of type T Pin
racette26-Nov-07 10:09
racette26-Nov-07 10:09 
QuestionGet_url: Firefox? Pin
Gofur Halmurat26-Nov-07 6:35
Gofur Halmurat26-Nov-07 6:35 
QuestionRe: Get_url: Firefox? Pin
David Crow26-Nov-07 7:23
David Crow26-Nov-07 7:23 
AnswerRe: Get_url: Firefox? Pin
Gofur Halmurat26-Nov-07 7:50
Gofur Halmurat26-Nov-07 7:50 
GeneralRe: Get_url: Firefox? Pin
ThatsAlok26-Nov-07 18:45
ThatsAlok26-Nov-07 18:45 
AnswerRe: Get_url: Firefox? Pin
Gofur Halmurat26-Nov-07 10:32
Gofur Halmurat26-Nov-07 10:32 
Questionbasic type action Pin
Joezer BH26-Nov-07 6:19
professionalJoezer BH26-Nov-07 6:19 
AnswerRe: basic type action Pin
led mike26-Nov-07 7:37
led mike26-Nov-07 7:37 
GeneralRe: basic type action Pin
Joezer BH26-Nov-07 7:45
professionalJoezer BH26-Nov-07 7:45 
GeneralRe: basic type action Pin
led mike26-Nov-07 9:52
led mike26-Nov-07 9:52 
Questionstdin always the keyboard ? Pin
Joezer BH26-Nov-07 6:17
professionalJoezer BH26-Nov-07 6:17 
AnswerRe: stdin always the keyboard ? Pin
Luc Pattyn26-Nov-07 6:30
sitebuilderLuc Pattyn26-Nov-07 6:30 
GeneralRe: stdin always the keyboard ? Pin
Joezer BH26-Nov-07 6:45
professionalJoezer BH26-Nov-07 6:45 
AnswerRe: stdin always the keyboard ? Pin
David Crow26-Nov-07 7:25
David Crow26-Nov-07 7:25 
GeneralRe: stdin always the keyboard ? Pin
Florin Crişan26-Nov-07 21:26
Florin Crişan26-Nov-07 21:26 
Questionfclose(f_ptr2) - "Access Violation or memery can not be read" Pin
mrby12326-Nov-07 6:07
mrby12326-Nov-07 6:07 

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.