std::list<MachineState*> zombs
我已经在我的声明中声明了
class CZombieView : public CWindowImpl<CZombieView>
{
public:
CZombieView();
void DrawGrid();
Gdiplus::Bitmap m_BitmapImage;
Gdiplus::Graphics m_GraphicsImage;
MachineState zombieTestState;
Machine<ZombieTraits> zombieMachine;
MachineState zombieTestState2;
MachineState zombieTestState3;
Machine<HumanTraits>humanMachine;
MachineState humanTestState;
MachineState humanTestState2;
MachineState humanTestState3;
std::list<MachineState*> zombs;
std::list<MachineState*> humans;
};
我已经宣布了另一个班级。欧普.cpp
class Op
{
public:
CZombieView * cz;
MachineState * neighboor;
MachineState * neighboor2;
void setNeighboor(MachineState * decoy); //
void setNeighboor2(MachineState * decoy2);
virtual void Execute(MachineState& state) = 0;
};
setNeighboor 函数将 CZombieView 的zombieTestState 设置为变量 neighboor。当我在设置邻居后尝试调用时cz->zombs.remove(neighboor)
,出现异常,并且我在 Visual Studio 上的调用堆栈指向const _Nodeptr _Phead = this->_Myhead;
...我不确定为什么会发生这种情况,或者这是否是删除对象的错误方法从列表中......任何输入将不胜感激
void Op::setNeighboor2(MachineState * decoy2)
{
neighboor2 = decoy2;
cz->zombs.remove(neighboor2);
std::cout<<"SET";
}
我的程序就停止了cz->zombs.remove(neighboor2)
,打印语句甚至没有被打印出来。