std::array<LINE,10> currentPaths=PossibleStrtPaths();
LINE s=shortestLine(currentPaths); //ERROR
LINE CShortestPathFinderView::shortestLine(std::array<LINE,10> *currentPaths)
{
std::array<LINE,10>::iterator iter;
LINE s=*(currentPaths+1); //ERROR
for(iter=currentPaths->begin()+1;iter<=currentPaths->end();iter++)
{
if(s.cost>iter->cost)
s=*iter;
}
std::remove(currentPaths->begin(),currentPaths->end(),s);
//now s contains the shortest partial path
return s;
}
在这两个陈述中,我都遇到了同样的错误: no suitable conversion from std::array<LINE,10U>*currentPaths to LINE
。为什么会这样?我应该以另一种方式传递数组吗?我也尝试过将currentPaths 作为引用传递,但它告诉我无法初始化该类型的引用。