Use a class destructor to cleanup instead of manually?

Started by
4 comments, last by johnnyBravo 20 years, 7 months ago
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
Advertisement
There is no problem at all.
[size="2"]I like the Walrus best.
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.

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

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

But make sure you CHECK before you denitialize(hit me) them.

.lick
http://sourceforge.net/docman/display_doc.php?docid=8673&group_id=9028

you''re heading the right way...

This topic is closed to new replies.

Advertisement