Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete operator?

Status
Not open for further replies.

Wolfie7873

Technical User
Jan 15, 2004
94
US
So I just read that in .NET if you declare a class using the __gc keyword then, the garbage collector does all of the memory management when dynamically allocated objects fall out of scope.

if i'm importing old code from a different compiler (g++), do I need to remove my explicit destructors, or can I leave them?

Eddie
 
No, keep as they are implemened and also as they are called e.g. implicit (when the object is out of the scope or delete is called) or explicit when you call the destructor like this virtual call: obj.~MyObject();
-obislavu-
 
One more thing, when call delete for a __gc class, the destructor is executed, but object is not freed from the memory. You may call for example delete for ten times on the same pointer. Each time the destructor will be executed, but after that, you may use that pointer as a valid object, as it was never deleted.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top