I have a base class:
class A {
protected:
static void* operator new (size_t size);
void operator delete (void *p);
public:
void Delete();
}
and then a subclass that calls Delete(), here are those function definitions (in a nutshell):
void* A::operator new (size_t size) {
return AllocMem(size);
}
void A::operator delete (void *p) {
LOG("Working!") ;
FreeMem(p);
}
void A::Delete() {
delete this;
}
My problem is that when I call Delete from the subclass, I can break in VC++ to the delete this function call, but don't get any breaks on the overridden operator, nor any log output. So my delete operator is never being called (my new operator IS being called, I checked)
Am I doing something wrong? Why wouldn't my delete operator get called, does it have something to do with explicitly using "delete this"?
class A {
protected:
static void* operator new (size_t size);
void operator delete (void *p);
public:
void Delete();
}
and then a subclass that calls Delete(), here are those function definitions (in a nutshell):
void* A::operator new (size_t size) {
return AllocMem(size);
}
void A::operator delete (void *p) {
LOG("Working!") ;
FreeMem(p);
}
void A::Delete() {
delete this;
}
My problem is that when I call Delete from the subclass, I can break in VC++ to the delete this function call, but don't get any breaks on the overridden operator, nor any log output. So my delete operator is never being called (my new operator IS being called, I checked)
Am I doing something wrong? Why wouldn't my delete operator get called, does it have something to do with explicitly using "delete this"?
Comment