我有一个错误:“ setShortPath”和“ setNodePath”的脱机定义与“ MyGraphBuilder”中的任何声明都不匹配CPP中的代码为:
// Mutator void MyGraphBuilder::setShortPath(vector <Vertex> PathVector) { ShortPath.clear(); ShortPath = PathVector; } void MyGraphBuilder::setNodePath(Vertex MyNode){ ShortPath.emplace_back(MyNode); };
虽然头文件中的代码为:
//Mutators
// function to assign Shortest path as a whole Vectore
void setShortPath(std::vector <Vertex> PathVector);
// function to assign Shortest path Vertex by Vertex
void setNodePath(Vertex);
我有一个错误:'setShortPath'和'setNodePath'的脱机定义与'MyGraphBuilder'中的任何声明都不匹配。CPP中的代码是:// Mutator void MyGraphBuilder :: ......
除非您在cpp中声明了using namespace std;
,否则由于std::
之前的定义中缺少vector
,因此声明和定义可能不匹配。在;
定义之后,您也不需要setNodePath
。