Click here to Skip to main content
15,914,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to copy file much faster? Pin
JudyL_MD19-Oct-07 4:01
JudyL_MD19-Oct-07 4:01 
GeneralRe: How to copy file much faster? Pin
Tydia-kun19-Oct-07 4:05
Tydia-kun19-Oct-07 4:05 
GeneralRe: How to copy file much faster? Pin
kcynic19-Oct-07 20:01
kcynic19-Oct-07 20:01 
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 
George_George wrote:
ust interested to learn how C++ implements delete this statement internally.


Internally (simplified!), all functions of an object are global, and take a first, hidden, parameter this, which points to a memory-chunk holding the data-members of the object.
So, when calling the same member function on different instantiations of Object, you are executing the same code with a different this-pointer. Also, delete only frees the memory-chunk the this-pointer points to. It does nothing to the code of a class.

So, a code containing
delete this;
is very possible: delete calls the destructor (with the this-pointer) as usually and then frees the memory-chunk and returns control to the calling code. The object is destroyed like any normal object.



Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
Douglas Adams, "Dirk Gently's Holistic Detective Agency"

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 
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 

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.