Click here to Skip to main content
15,891,423 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to use an image converter in my application? Pin
kapardhi20-May-09 21:17
kapardhi20-May-09 21:17 
AnswerRe: How to use an image converter in my application? Pin
Hamid_RT20-May-09 21:20
Hamid_RT20-May-09 21:20 
GeneralRe: How to use an image converter in my application? Pin
kapardhi20-May-09 21:31
kapardhi20-May-09 21:31 
AnswerRe: How to use an image converter in my application? Pin
ThatsAlok20-May-09 21:24
ThatsAlok20-May-09 21:24 
GeneralRe: How to use an image converter in my application? Pin
kapardhi20-May-09 21:34
kapardhi20-May-09 21:34 
GeneralRe: How to use an image converter in my application? Pin
ThatsAlok20-May-09 21:54
ThatsAlok20-May-09 21:54 
Questiondelete operator in C++ Pin
QuickDeveloper20-May-09 20:48
QuickDeveloper20-May-09 20:48 
AnswerRe: delete operator in C++ Pin
Cedric Moonen20-May-09 21:37
Cedric Moonen20-May-09 21:37 
QuickDeveloper wrote:
the problem is even after i deleted pointer p ..the call to Showi() works....does it mean p is deleted after sometime(since i heard VS 2005 uses GC)?


No, there's no such thing as garbage collector in C++. The fact that the call doesn't crash is probably pure luck (edit: see below). In fact you can always call a non virtual function on an object and the function will get called without problems (even if your object is NULL). The problem arise when you try to access data member of the class, in that case the troubles begin Smile | :) . If we take the example of the NULL pointer, an offset will be added to the address of the this pointer (NULL in that case) to be able to reach a specific member of the class. But the address is still invalid (NULL + an offset is still invalid).
In your case, what happened certainly is that when the function is called, the memory of your object has been released but as you didn't allocate any memory after that, the data is still in memory. Now, if you add some code to allocate memory just after the delete, it is possible that the memory used by your class previously will be overwritten by new data.

In fact, when you delete an object, it simply means that the memory is not protected anymore and that it can be reused for something else. If nobody is using it, it still contains the old data.

EDIT: in fact the call will never crash because even if the memory of your integer is overwritten, it can always be accessed without any problem. Of course, in that case you will end up with corrupted data.

Cédric Moonen
Software developer

Charting control [v2.0]
OpenGL game tutorial in C++

Questionpassing value from C# to c++ Pin
mutpan20-May-09 19:40
mutpan20-May-09 19:40 
GeneralRe: passing value from C# to c++ Pin
norish21-May-09 1:34
norish21-May-09 1:34 
QuestionTextOut and distance between strings Pin
prithaa20-May-09 18:35
prithaa20-May-09 18:35 
GeneralRe: TextOut and distance between strings Pin
Michael Dunn20-May-09 18:48
sitebuilderMichael Dunn20-May-09 18:48 
GeneralRe: TextOut and distance between strings Pin
prithaa20-May-09 19:09
prithaa20-May-09 19:09 
GeneralRe: TextOut and distance between strings Pin
Michael Dunn20-May-09 19:32
sitebuilderMichael Dunn20-May-09 19:32 
GeneralRe: TextOut and distance between strings Pin
prithaa20-May-09 19:42
prithaa20-May-09 19:42 
GeneralRe: TextOut and distance between strings Pin
CPallini21-May-09 0:05
mveCPallini21-May-09 0:05 
QuestionMFC APPLICATION Pin
kjayalakshmi20-May-09 18:28
kjayalakshmi20-May-09 18:28 
AnswerRe: MFC APPLICATION Pin
Hamid_RT20-May-09 19:17
Hamid_RT20-May-09 19:17 
AnswerRe: MFC APPLICATION Pin
ThatsAlok20-May-09 21:30
ThatsAlok20-May-09 21:30 
QuestionConvert C# to C++ MFC? Pin
nhenden6700020-May-09 17:33
nhenden6700020-May-09 17:33 
AnswerRe: Convert C# to C++ MFC? Pin
Chandrasekharan P20-May-09 17:49
Chandrasekharan P20-May-09 17:49 
AnswerRe: Convert C# to C++ MFC? Pin
Hamid_RT20-May-09 19:17
Hamid_RT20-May-09 19:17 
JokeRe: Convert C# to C++ MFC? Pin
ThatsAlok20-May-09 21:32
ThatsAlok20-May-09 21:32 
GeneralRe: Convert C# to C++ MFC? Pin
Hamid_RT21-May-09 2:32
Hamid_RT21-May-09 2:32 
JokeRe: Convert C# to C++ MFC? Pin
ThatsAlok20-May-09 21:31
ThatsAlok20-May-09 21:31 

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.