Jump to content
  • Advertisement

Archived

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

EvilCrap

convention?

This topic is 6115 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi! if i make a class with a callable destructor, like Release(), should i not make a default destructor? class C { public: Destroy(); private: }; and, if i did make a default destructor, is it bad to call my Destuctor in it? class C { public: ~C() {if (Destroyed != NULL) Destroy();} Destroy(); public: mydynamicstuffs *Destroyed; };

Share this post


Link to post
Share on other sites
Advertisement
I think it is a good solution to make your own Destroy function when you need to control the destruction of the object, however I would personally put any check that the object is still alive in the destroy function itself, such as:

class myclass
{
bool m_Destroyed;
public:
myclass() {Clear();};
~myclass() {Destroy();};

bool Clear();
bool Destroy();
};

bool myclass::Clear()
{
//Nullify things - reset members to start state
}

bool myclass::Destroy()
{
if(m_bDestroyed)
return true;

//Destroy things
//Nullify things - reset members to start state
Clear();
}

Advantages: you can get a return value when destroying and you can destroy things on demand.

I am actually a Swede, living in paradise.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!