我理解为什么会发生这种情况,但我一直试图解决它......这是我的代码在我的程序退出时生成错误(因此导致崩溃)时所做的事情......
pure virtual method called
SomeClass::~SomeClass()
{
BaseClassObject->SomePureVirtualMethod(this);
}
void DerivedClass::SomePureVirtualMethod(SomeClass* obj)
{
//Do stuff to remove obj from a collection
}
我从来没有打电话,new SomeClass但我有一个QList<SomeClass*>我附加SomeClass*对象的电话。这个析构函数的目的SomeClass是告诉从它的集合中DerivedClass删除一个特定的实例。SomeClassQList<SomeClass*>
所以,在一个具体的例子中......
BaseClass=Shape
DerivedClass=Triangle
SomeClass=ShapeProperties拥有对Shape
所以,我从来没有打电话给,new ShapeProperties但我有QList<ShapeProperties*>一个Triangle. 中的析构函数ShapeProperties是告诉从它的集合中Triangle删除一个特定的属性。ShapePropertiesQList<ShapeProperties*>