Archived

This topic is now archived and is closed to further replies.

johnnyBravo

Use a class destructor to cleanup instead of manually?

Recommended Posts

johnnyBravo    100
I''m wondering if its ok to use a class destructor to clean up the directx devices etc. Like I have all my direct3d commands in a class, so i thought i could just use the destructor to clean up. Like I have no need to manually do it, only when the program ends. Thanks

Share this post


Link to post
Share on other sites
quote:
Original post by johnnyBravo
I''m wondering if its ok to use a class destructor to clean up the directx devices etc.

Like I have all my direct3d commands in a class, so i thought i could just use the destructor to clean up. Like I have no need to manually do it, only when the program ends.

Thanks

Yeah, in fact, that''s exactly what you should be doing assuming that the interfaces pointers are encapsulated in the object being destructed, of course.

Share this post


Link to post
Share on other sites
S1CA    1418
Also assuming none of the classes have global or static instances. Only put system level stuff in destructors if you''re 100% certain of WHEN destruction will happen.

With global or static instances that''ll be AFTER you return control from WinMain back to the CRT process startup code.

--
Simon O''Connor
3D Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
http://sourceforge.net/docman/display_doc.php?docid=8673&group_id=9028

you''re heading the right way...

Share this post


Link to post
Share on other sites