Click here to Skip to main content
15,896,207 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Managing PushButton notifications under MFC Pin
Richard MacCutchan26-Jul-11 23:11
mveRichard MacCutchan26-Jul-11 23:11 
GeneralRe: Managing PushButton notifications under MFC Pin
tiwal26-Jul-11 23:37
tiwal26-Jul-11 23:37 
GeneralRe: Managing PushButton notifications under MFC Pin
Richard MacCutchan26-Jul-11 23:43
mveRichard MacCutchan26-Jul-11 23:43 
GeneralRe: Managing PushButton notifications under MFC Pin
tiwal26-Jul-11 23:56
tiwal26-Jul-11 23:56 
GeneralRe: Managing PushButton notifications under MFC Pin
Richard MacCutchan27-Jul-11 2:39
mveRichard MacCutchan27-Jul-11 2:39 
GeneralRe: Managing PushButton notifications under MFC Pin
tiwal27-Jul-11 3:07
tiwal27-Jul-11 3:07 
GeneralRe: Managing PushButton notifications under MFC Pin
Richard MacCutchan27-Jul-11 3:19
mveRichard MacCutchan27-Jul-11 3:19 
GeneralRe: Managing PushButton notifications under MFC Pin
tiwal27-Jul-11 3:23
tiwal27-Jul-11 3:23 
GeneralRe: Managing PushButton notifications under MFC Pin
Richard MacCutchan27-Jul-11 3:29
mveRichard MacCutchan27-Jul-11 3:29 
AnswerRe: Managing PushButton notifications under MFC Pin
Madhu Nair26-Jul-11 23:35
Madhu Nair26-Jul-11 23:35 
GeneralRe: Managing PushButton notifications under MFC [modified] Pin
tiwal26-Jul-11 23:46
tiwal26-Jul-11 23:46 
QuestionHow to compile a file using unicode charset Pin
Cold_Fearing_Bird26-Jul-11 21:50
Cold_Fearing_Bird26-Jul-11 21:50 
AnswerRe: How to compile a file using unicode charset Pin
Madhu Nair26-Jul-11 22:01
Madhu Nair26-Jul-11 22:01 
QuestionDelete doesn't ^delete^ a reference? Pin
Dean Seo25-Jul-11 20:58
Dean Seo25-Jul-11 20:58 
AnswerRe: Delete doesn't ^delete^ a reference? Pin
Richard MacCutchan25-Jul-11 21:24
mveRichard MacCutchan25-Jul-11 21:24 
GeneralRe: Delete doesn't ^delete^ a reference? Pin
Dean Seo26-Jul-11 14:11
Dean Seo26-Jul-11 14:11 
AnswerRe: Delete doesn't ^delete^ a reference? Pin
Chris Losinger26-Jul-11 1:45
professionalChris Losinger26-Jul-11 1:45 
GeneralRe: Delete doesn't ^delete^ a reference? Pin
Dean Seo26-Jul-11 14:10
Dean Seo26-Jul-11 14:10 
AnswerRe: Delete doesn't ^delete^ a reference? Pin
jschell26-Jul-11 9:48
jschell26-Jul-11 9:48 
GeneralRe: Delete doesn't ^delete^ a reference? Pin
Dean Seo26-Jul-11 14:09
Dean Seo26-Jul-11 14:09 
AnswerRe: Delete doesn't ^delete^ a reference? Pin
Stefan_Lang27-Jul-11 3:00
Stefan_Lang27-Jul-11 3:00 
new does three things:
1. allocate memory from the heap
2. initialize the object at the resulting memory location
3. return a pointer to this new object.

What it does not do is set the value of your pointer variable - this is done by the assignment operator '='.

delete does the reverse, in reverse order:
1. take a pointer to an existing object
2. destruct the object
3. deallocate the memory it occupied

What it does not is reset the value of your pointer variable.

Technically it wouldn't be so hard to make delete also reset your pointer variable to 0, but since 'cleaning up' is often done at the end of a function or the end of the scope a pointer is defined in, it is usually not neccessary.

Nevertheless it is a good idea to always explicitely set a pointer to 0 after calling delete on it! Even if your delete is the very last line in your code, someone might later add code to that function, past that line.

That said, it might have been better if the C++ standard required the delete operator to also set the pointer to 0. But it doesn't. Of course, it is possible to overwrite delete, if you really want it that way... Wink | ;)
GeneralRe: Delete doesn't ^delete^ a reference? Pin
jschell27-Jul-11 12:32
jschell27-Jul-11 12:32 
QuestionWorking with XML file in MFC Dialog based application? Pin
Le@rner25-Jul-11 20:27
Le@rner25-Jul-11 20:27 
AnswerRe: Working with XML file in MFC Dialog based application? Pin
Rajesh R Subramanian25-Jul-11 20:31
professionalRajesh R Subramanian25-Jul-11 20:31 
GeneralRe: Working with XML file in MFC Dialog based application? Pin
Le@rner25-Jul-11 21:02
Le@rner25-Jul-11 21: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.