M
mc
Hi Experts,
This may be obvious but I can't find anything one way or another. We have
a class which is always allocated using new, e.g. Foo* foo = new Foo() so we
came up with the idea of releasing the memory from the destructor as
follows:
Foo::Foo()
{
// Initialize stuff
m_This = this; // m_This is a "void*"
}
Foo::~Foo()
{
// Release all resources
// and finally the memory
delete m_This;
}
It's been working fine so far (both Windows and Linux) but we're wondering
about it being either the worse thing to do..... Any thoughts.
Thank you.
Regards,
MC
This may be obvious but I can't find anything one way or another. We have
a class which is always allocated using new, e.g. Foo* foo = new Foo() so we
came up with the idea of releasing the memory from the destructor as
follows:
Foo::Foo()
{
// Initialize stuff
m_This = this; // m_This is a "void*"
}
Foo::~Foo()
{
// Release all resources
// and finally the memory
delete m_This;
}
It's been working fine so far (both Windows and Linux) but we're wondering
about it being either the worse thing to do..... Any thoughts.
Thank you.
Regards,
MC