好的,这是我的问题:
Move class
,变量Move *subMove
指向“subMove”vector
Move
vector<Move>::iterator
个int Game::doSth(Move & pv)
{
vector<Move> moves;
this->possibleMoves(moves);
for (std::vector<Move>::iterator move = moves.begin(); move!=moves.end(); ++move)
{
// Do sth
int subResult = this->doSth(*move);
if (someConditionIsTrue)
{
// yep, we want to store THIS move as a submove
// This works - without memory errors -
// but still something goes weird, so I'd prefer creating a new object
pv.subMove = &(*move);
// Also tried something along the lines of `pv.subMove = new Move(*move)`
// - yes there is an appropriate copy constructor -
// but this leads to a `segmentation fault` error
}
}
// return something;
}
以下是问题的出现......
我的代码(大致)如下所示:
{{1}}
有什么想法吗?