Board index » cppbuilder » when to assign NULL to pointer
George
CBuilder Developer |
George
CBuilder Developer |
when to assign NULL to pointer2005-01-11 01:48:08 AM cppbuilder10 Hi all, I have a pointer to mdi child form. let's say TmyMDIChild *myPointer=new TmyMDIChild(this); and then on OnClose event I have Action=caFree; but I as well need to asign to myPointer=NULL; at the moment when mdichild is closed... when can I do that? in OnClose event as well??? or in destructor of mdi child is better??? thanks in advance |
Hans Galema
CBuilder Developer |
2005-01-11 07:19:31 AM
Re:when to assign NULL to pointer
George wrote:
Quotebut I as well need to asign to myPointer=NULL; where OnCloseQuery always fires. But not nulling a pointer where the application terminates does not matter. Hans. |
Remy Lebeau (TeamB)
CBuilder Developer |
2005-01-11 09:47:32 AM
Re:when to assign NULL to pointer
"George" < XXXX@XXXXX.COM >wrote in message
QuoteI have a pointer to mdi child form. to create multiple form instances. The code you showed is using the pointer as a local variable, so chances are it won't even be in scope anymore by the time the form is closed. Gambit {smallsort} |
George
CBuilder Developer |
2005-01-11 08:05:01 PM
Re:when to assign NULL to pointer
thanks for reply...
the code that I showed doesn't really show the real code! it was just for a question. and I know I don't need to set it to NULL.. I just need in other part of a program to check if that form is created, and thought that would be the best way to know it. thanks for reply to everone! "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Remy Lebeau (TeamB)
CBuilder Developer |
2005-01-12 03:10:03 AM
Re:when to assign NULL to pointer
"George" < XXXX@XXXXX.COM >wrote in message
Quotethe code that I showed doesn't really show the real code! Quoteand I know I don't need to set it to NULL.. either a member of the main form, or declared globally, in order to do what you are asking. Otherwise, the code will have to loop through all of the available MDI child forms until it finds the one it is interested in. Gambit |