Click here to Skip to main content
15,915,019 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionneed an approach. Pin
narayanagvs18-Oct-07 21:40
narayanagvs18-Oct-07 21:40 
AnswerRe: need an approach. Pin
Nelek18-Oct-07 21:59
protectorNelek18-Oct-07 21:59 
GeneralRe: need an approach. Pin
Matthew Faithfull18-Oct-07 23:26
Matthew Faithfull18-Oct-07 23:26 
Questiondelete this Pin
George_George18-Oct-07 21:10
George_George18-Oct-07 21:10 
AnswerRe: delete this Pin
jhwurmbach18-Oct-07 21:40
jhwurmbach18-Oct-07 21:40 
GeneralRe: delete this Pin
Sameerkumar Namdeo18-Oct-07 22:03
Sameerkumar Namdeo18-Oct-07 22:03 
GeneralRe: delete this Pin
George_George18-Oct-07 23:01
George_George18-Oct-07 23:01 
AnswerRe: delete this Pin
Roger Stoltz18-Oct-07 22:08
Roger Stoltz18-Oct-07 22:08 
George_George wrote:
how could it destroys itself from itself?


Confused | :confused:
Not sure what you mean by that...
Nothing destroys itself "from" itself. Every call chain has its root in the system; every process and thread.
If the process or thread returns from its controlling function, the system will remove it from the scheduler and destroy it.
If you debug your application and have a look in the call stack, you'll see that the first stack frame is from the system.
Don't confuse the code loaded for the component and the object on the heap.

This question could be about COM. It doesn't have to be, but we can use it as an example.
When you call Release on an interface, the reference count is decreased and if it reaches zero the component "destroys itself", i.e. calls delete this and thus removes the object from the heap. When returning from the Release subroutine, the client continues executing. This means that the component is destroyed, but in a call chain that originates from the client. The code for the component would still be there, but the object on the heap is destroyed.

I hope this answers your question.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown

GeneralRe: delete this Pin
George_George18-Oct-07 22:59
George_George18-Oct-07 22:59 
GeneralRe: delete this Pin
Roger Stoltz18-Oct-07 23:09
Roger Stoltz18-Oct-07 23:09 
GeneralRe: delete this Pin
George_George19-Oct-07 3:52
George_George19-Oct-07 3:52 
QuestionDllMain Pin
George_George18-Oct-07 20:53
George_George18-Oct-07 20:53 
AnswerRe: DllMain Pin
aks.18-Oct-07 22:00
aks.18-Oct-07 22:00 
GeneralRe: DllMain Pin
George_George18-Oct-07 22:40
George_George18-Oct-07 22:40 
GeneralRe: DllMain Pin
Matthew Faithfull18-Oct-07 22:58
Matthew Faithfull18-Oct-07 22:58 
GeneralRe: DllMain Pin
George_George19-Oct-07 4:00
George_George19-Oct-07 4:00 
AnswerRe: DllMain Pin
Nibu babu thomas18-Oct-07 23:20
Nibu babu thomas18-Oct-07 23:20 
GeneralRe: DllMain Pin
George_George19-Oct-07 3:57
George_George19-Oct-07 3:57 
QuestionHow to create namespace? Pin
TooShy2Talk18-Oct-07 20:48
TooShy2Talk18-Oct-07 20:48 
AnswerRe: How to create namespace? Pin
Cedric Moonen18-Oct-07 20:51
Cedric Moonen18-Oct-07 20:51 
QuestionRe: How to create namespace? Pin
TooShy2Talk18-Oct-07 21:00
TooShy2Talk18-Oct-07 21:00 
AnswerRe: How to create namespace? Pin
Cedric Moonen18-Oct-07 21:05
Cedric Moonen18-Oct-07 21:05 
GeneralRe: How to create namespace? Pin
TooShy2Talk18-Oct-07 21:31
TooShy2Talk18-Oct-07 21:31 
GeneralRe: How to create namespace? Pin
Cedric Moonen18-Oct-07 21:54
Cedric Moonen18-Oct-07 21:54 
GeneralRe: How to create namespace? Pin
Cedric Moonen18-Oct-07 21:57
Cedric Moonen18-Oct-07 21:57 

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.