Hey guys i wrote a quick test. I want delete to call deleteMe which will then delete itself. The purpose of this is so i can delete obj normally which are allocated by a lib. (i dont want any crashes due to crt or w/e).
With delete this i get a stackoverflow, without it msvc says i leaked 4 bytes. When i dont call test i leak 0. How do i delete w/o a recursion problem? -edit- to make this more clear. I want the LIB to call delete (thus deleteMe) instead of the program due to crt
class B
{
public:
virtual void deleteMe()=0;
static void operator delete (void* p) { ((B*)p)->deleteMe(); }
};
class D : public B
{
public:
void deleteMe() {
delete this;
}
};
int test()
{
B *p = new D;
delete p;
return 0;
}