How to Distroy the object pointer that are taken be new(ELeave)
| Mon, 2006-05-22 06:16 | |
|
Hi,
Can any body tell me how a pointer can be destried after it is used, that is created by using new (ELeave). For example. CAknInformationNote* note = new (ELeave) CAknInformationNote; note->ExecuteLD(*buf); Now after the execution of note how can I destory the note Thanks in advance |
|






Forum posts: 98
Forum posts: 38
but how can I distroy other pointers like:
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(2);
Thank in advance for you reply again
Forum posts: 37
If you don't have a class member as in your example you have to destroy the pointer by simply delete it in most cases (and use the cleanupstack if you are doing something that can Leave).
Class members normally destroyed in the destrcutor and you should not use the cleanupstack for them.
For pointer arrays depending on the type you need to call ResetAndDestroy() before deleting the pointer to ensure all members of the array get cleaned as well.
BR
have fun...
Rayko Enz
www.sic-software.com
Forum posts: 723
but how can I distroy other pointers like:
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(2);
Thank in advance for you reply again
Normally you have to treat these objects as if they had been created simply with new (i.e. without ELeave). That is, call delete on them if you want to destroy them.
Other than that, I agree with rayko_enz that you should use the cleanup stack in most cases.
Tote
Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/