Click here to Skip to main content
15,892,674 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Cross compiling using Eclipse C/C++ CDT Pin
CPallini29-Jun-14 21:52
mveCPallini29-Jun-14 21:52 
QuestionWhen to delete a pointer (C++)... Pin
DanielSheets26-Jun-14 5:24
DanielSheets26-Jun-14 5:24 
AnswerRe: When to delete a pointer (C++)... Pin
Chris Losinger26-Jun-14 5:32
professionalChris Losinger26-Jun-14 5:32 
AnswerRe: When to delete a pointer (C++)... Pin
Orjan Westin26-Jun-14 5:47
professionalOrjan Westin26-Jun-14 5:47 
AnswerRe: When to delete a pointer (C++)... Pin
David Crow26-Jun-14 7:21
David Crow26-Jun-14 7:21 
AnswerRe: When to delete a pointer (C++)... Pin
Freak3027-Jun-14 3:31
Freak3027-Jun-14 3:31 
GeneralRe: When to delete a pointer (C++)... Pin
Stefan_Lang30-Jun-14 22:53
Stefan_Lang30-Jun-14 22:53 
GeneralRe: When to delete a pointer (C++)... Pin
Freak301-Jul-14 22:11
Freak301-Jul-14 22:11 
Stefan_Lang wrote:


Freak30 wrote:
On a more general note: Deleting a pointer on
app exit doesn't make much sense,

I don't quite agree. Calling
delete does more than just free memory. E. g. a the destructor of a file class
might be implemented to flush the buffers and close the file properly. Not
calling it would cause data loss! Other examples could be objects that stream
data to the display or sound card: not closing them down properly may result in
nasty artifacts. or think of a web connection to your bank account - do you want
to leave it open?

You conveniently left the conditional part of my sentence out of the quote. If you e.g. have a text editor application that only allows opening one file at the time and the only way to close the file is by closing the application, of course you need to delete the file object on application exit. But if you had an editor that can keep open multiple files at once and one of the files is closed, would you keep the object for this file active and delete it on application exit? I would delete it as soon as the file is closed.

So my intention wasn't to say that you should never delete a pointer on appliaction exit. I wanted to say that it isn't a good idea to keep every pointer and delete all ofthem on application exit.
The good thing about pessimism is, that you are always either right or pleasently surprised.

GeneralRe: When to delete a pointer (C++)... Pin
Stefan_Lang1-Jul-14 22:23
Stefan_Lang1-Jul-14 22:23 
GeneralRe: When to delete a pointer (C++)... Pin
Erik Westermann14-Jul-14 3:40
professionalErik Westermann14-Jul-14 3:40 
AnswerRe: When to delete a pointer (C++)... Pin
CPallini27-Jun-14 7:31
mveCPallini27-Jun-14 7:31 
AnswerRe: When to delete a pointer (C++)... Pin
DanielSheets27-Jun-14 7:40
DanielSheets27-Jun-14 7:40 
GeneralRe: When to delete a pointer (C++)... Pin
Derek Tortonian28-Jun-14 8:50
Derek Tortonian28-Jun-14 8:50 
GeneralRe: When to delete a pointer (C++)... Pin
Stefan_Lang30-Jun-14 23:05
Stefan_Lang30-Jun-14 23:05 
GeneralRe: When to delete a pointer (C++)... Pin
Albert Holguin1-Jul-14 9:17
professionalAlbert Holguin1-Jul-14 9:17 
AnswerRe: When to delete a pointer (C++)... Pin
Joe Woodbury1-Jul-14 6:23
professionalJoe Woodbury1-Jul-14 6:23 
AnswerRe: When to delete a pointer (C++)... Pin
Satya Chamakuri8-Aug-14 23:52
Satya Chamakuri8-Aug-14 23:52 
QuestionMessage Removed Pin
25-Jun-14 22:04
_Flaviu25-Jun-14 22:04 
QuestionBeginner- Floating point character conversion character Pin
BeingGokul24-Jun-14 7:17
BeingGokul24-Jun-14 7:17 
AnswerRe: Beginner- Floating point character conversion character Pin
CPallini24-Jun-14 9:06
mveCPallini24-Jun-14 9:06 
AnswerRe: Beginner- Floating point character conversion character Pin
David Crow24-Jun-14 10:19
David Crow24-Jun-14 10:19 
AnswerRe: Beginner- Floating point character conversion character Pin
M.FarrukhFaizy27-Jun-14 8:45
M.FarrukhFaizy27-Jun-14 8:45 
AnswerRe: Beginner- Floating point character conversion character Pin
Satya Chamakuri9-Aug-14 1:46
Satya Chamakuri9-Aug-14 1:46 
QuestionGraphics Pipeline questions Ortho projection Pin
shiftwik23-Jun-14 12:04
shiftwik23-Jun-14 12:04 
QuestionTwo ChlidFrames in MDI application? Pin
Member 1074879523-Jun-14 8:59
Member 1074879523-Jun-14 8:59 

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.