错误:脱机定义,我不知道如何解决]]

问题描述 投票:0回答:1

我有一个错误:“ 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 :: ......

c++ boost graph boost-graph
1个回答
0
投票

除非您在cpp中声明了using namespace std;,否则由于std::之前的定义中缺少vector,因此声明和定义可能不匹配。在;定义之后,您也不需要setNodePath

© www.soinside.com 2019 - 2024. All rights reserved.