Click here to Skip to main content
16,005,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPreventing redraw. Pin
paper6714-Jul-07 10:07
paper6714-Jul-07 10:07 
AnswerRe: Preventing redraw. Pin
Mark Salsbery14-Jul-07 11:37
Mark Salsbery14-Jul-07 11:37 
QuestionCache hit rates Pin
tom groezer14-Jul-07 10:00
tom groezer14-Jul-07 10:00 
AnswerRe: Cache hit rates Pin
Steve Echols14-Jul-07 18:31
Steve Echols14-Jul-07 18:31 
GeneralRe: Cache hit rates Pin
David Crow16-Jul-07 4:54
David Crow16-Jul-07 4:54 
AnswerRe: Cache hit rates Pin
Randor 15-Jul-07 0:37
professional Randor 15-Jul-07 0:37 
QuestionObject return by value Pin
tom groezer14-Jul-07 9:30
tom groezer14-Jul-07 9:30 
AnswerRe: Object return by value Pin
DevMentor.org14-Jul-07 10:04
DevMentor.org14-Jul-07 10:04 
first of all, you never return a reference to an auto object( one created on the stack) because once you leave that scope, the object self destructs and you're left with a reference to nothing!

also you should not create an object on the heap and then return a reference to that object, because then you will have a memory leak because the allocated memory is never freed, the object done not self destruct when the reference goes out of scope!!!

would be cool if it did, but it doesn't.

so return a object on the stack, make sure the object can copy itself correctly if you're going to return objects by values, that is make sure the object has a copy constructor that does all the right things if you're doing anything specialized with that object, otherwise the complier will try to do a good job in trying to copy only auto class members, for pointer only the what the pointer points to will get copied but not what is pointer do! this is call a shallow copy....a deep copy is something that makes a copy of the pointer to things, but you will not have to worry about this when you're returning objects by value.

you will have to worry about this if you're want to clone an object, then you need to do a deep copy!

Yours Truly, The One and Only!

GeneralRe: Object return by value Pin
tom groezer14-Jul-07 13:54
tom groezer14-Jul-07 13:54 
GeneralRe: Object return by value Pin
DevMentor.org14-Jul-07 16:37
DevMentor.org14-Jul-07 16:37 
GeneralRe: Object return by value Pin
Mark Salsbery14-Jul-07 16:43
Mark Salsbery14-Jul-07 16:43 
GeneralRe: Object return by value Pin
tom groezer14-Jul-07 21:12
tom groezer14-Jul-07 21:12 
GeneralRe: Object return by value Pin
Mark Salsbery14-Jul-07 21:29
Mark Salsbery14-Jul-07 21:29 
QuestionRandom text Pin
dellthinker14-Jul-07 9:26
dellthinker14-Jul-07 9:26 
AnswerRe: Random text Pin
Perspx14-Jul-07 10:59
Perspx14-Jul-07 10:59 
AnswerRe: Random text Pin
#realJSOP15-Jul-07 2:01
professional#realJSOP15-Jul-07 2:01 
Questionwrong code Pin
tom groezer14-Jul-07 7:05
tom groezer14-Jul-07 7:05 
AnswerRe: wrong code Pin
Paul Conrad14-Jul-07 7:25
professionalPaul Conrad14-Jul-07 7:25 
AnswerRe: wrong code Pin
Mark Salsbery14-Jul-07 7:27
Mark Salsbery14-Jul-07 7:27 
AnswerRe: wrong code Pin
Mark Salsbery14-Jul-07 7:32
Mark Salsbery14-Jul-07 7:32 
GeneralRe: wrong code Pin
Paul Conrad14-Jul-07 7:37
professionalPaul Conrad14-Jul-07 7:37 
AnswerRe: wrong code Pin
#realJSOP15-Jul-07 2:03
professional#realJSOP15-Jul-07 2:03 
QuestionFP Question Pin
Cmania14-Jul-07 7:02
Cmania14-Jul-07 7:02 
AnswerRe: FP Question Pin
Mike Dimmick14-Jul-07 9:22
Mike Dimmick14-Jul-07 9:22 
QuestionNull pointer Pin
tom groezer14-Jul-07 7:02
tom groezer14-Jul-07 7:02 

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.