Juergen Wolther
December 4th, 2001, 09:38 AM
hi,
I tried to implement the following (stripped down to the essencials):
// first a usual class like you see it everywhere as base-class
class SomeBaseClassA
{
private:
int iSomeMemberA1;
int iSomeMemberA2;
public:
void SomeFunctionA1(){};
void SomeFunctionA2(){};
};
// now a abstract base-class (I think this is the problem)
class SomeBaseClassB
{
public:
virtual void SomeFunctionB(SomeOtherClass *pInstance) = 0;
};
// ok and now a derived class, derived from the classes shown above
class DerivedClass : public SomeBaseClassA, SomeBaseClassB
{
// Overriding the abstract function of SomeClassB
void SomeFunctionB(SomeOtherClass *pInstance){};
};
// Ok, and now a sample-code to use the construct shown above
// just to show you the problem
DerivedClass *pInstance = new DerivedClass();
// doing some not dangerous things with the class-instance
// but SURPRISE: in the next line of code the program crashes with a page-fault
delete pInstance;
that's it ! destroying the instance causes a page-fault. I am not doing any weird things in any destructor. in fact I have NO destructors defined at all by now.
if I only derive DerivedClass from SomeClassA, which is not abstract, everything works fine and no page-fault occurs.
Ah yeah, right before the page-fault I get the following error-dialog from the runtime:
=======================================================
Debug Assertion Failed
Program: Name of my Program
File: dbgheap.c
Line: 1017
Expression: BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
...and some advises to try to debug the program.
=======================================================
do you know why this is so ? did I something wrong in deriving or declaring. I have no clue about it.
thanx in advance
Juergen
I tried to implement the following (stripped down to the essencials):
// first a usual class like you see it everywhere as base-class
class SomeBaseClassA
{
private:
int iSomeMemberA1;
int iSomeMemberA2;
public:
void SomeFunctionA1(){};
void SomeFunctionA2(){};
};
// now a abstract base-class (I think this is the problem)
class SomeBaseClassB
{
public:
virtual void SomeFunctionB(SomeOtherClass *pInstance) = 0;
};
// ok and now a derived class, derived from the classes shown above
class DerivedClass : public SomeBaseClassA, SomeBaseClassB
{
// Overriding the abstract function of SomeClassB
void SomeFunctionB(SomeOtherClass *pInstance){};
};
// Ok, and now a sample-code to use the construct shown above
// just to show you the problem
DerivedClass *pInstance = new DerivedClass();
// doing some not dangerous things with the class-instance
// but SURPRISE: in the next line of code the program crashes with a page-fault
delete pInstance;
that's it ! destroying the instance causes a page-fault. I am not doing any weird things in any destructor. in fact I have NO destructors defined at all by now.
if I only derive DerivedClass from SomeClassA, which is not abstract, everything works fine and no page-fault occurs.
Ah yeah, right before the page-fault I get the following error-dialog from the runtime:
=======================================================
Debug Assertion Failed
Program: Name of my Program
File: dbgheap.c
Line: 1017
Expression: BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
...and some advises to try to debug the program.
=======================================================
do you know why this is so ? did I something wrong in deriving or declaring. I have no clue about it.
thanx in advance
Juergen