Hi,
I'm overriding my operator new and operator delete for two classes,
one inherited from the other, so I can use my own memory pool. A
simplified version of what I have is below:
class BaseClass {
BaseClass();
virtual ~BaseClass();
virtual void baseFunction();
static void operator delete(void* mem);
};
class InheritedClass : public BaseClass {
IneritedClass();
~InheritedClass();
void baseFunction();
void nonBaseFunction();
static void operator delete(void* mem);
};
I'm testing some things by making operator delete() do nothing, so the
memory shouldn't be deallocated. I've also made the ~BaseClass() and
~InheritedClass() functions do nothing. When I call delete on an
InheritedClass object, if I try to then call any inherited function on
that object (in this example, baseFunction()) I get a crash. If I call
a non-inherited function (nonBaseFunction() in this example) then it
goes along fine and nothing bad happens, as I would epect the inherited
function to have done (since, again, no memory should be deallocated).
In my actual code, I've tested to make sure that the delete call is
actually going through my InheritedClass's operator delete function,
and that it isn't doing anything in the base class's operator delete
function, though both have them defined to do nothing. But it seems
that delete is doing something more than what I define in that
function, and it's messing up things dealing with inheritance. I'm
using Visual Studio 2005. Any ideas would be greatly appreciated.
Tom