add_edge导致"no function to call error"
add_edge causing "no function to call error"
我在我的add_edge函数上获得了"无函数要调用"。Boost肯定是正确包含的,因此我认为这不是问题。这是称为
的功能void initializeGraph(Graph &g,
Graph::vertex_descriptor &start,
Graph::vertex_descriptor &end, ifstream &fin)
// Initialize g using data from fin. Set start and end equal
// to the start and end nodes.
{
edgeProperties e;
int n, i, j;
int startId, endId;
fin >> n;
fin >> startId >> endId;
Graph::vertex_descriptor v;
// Add nodes.
for (int i = 0; i < n; i++)
{
v = add_vertex(g);
if (i == startId)
start = v;
if (i == endId)
end = v;
}
while (fin.peek() != '.')
{
fin >> i >> j >> e.weight;
add_edge(i,j,e,g);
}
}
这就是我称之为函数的方式:
Graph g;
Graph::vertex_descriptor start, end, curr;
initializeGraph(g, start, end, infile);
关于为什么发生这种情况的任何想法都会很棒,因为我真的迷路了!
您无法提供一个独立的示例。从我看到的东西中拼凑出最低限度,没有问题:
活在coliru
#include <boost/graph/adjacency_list.hpp>
#include <fstream>
struct edgeProperties {
double weight;
};
using Graph = boost::adjacency_list<boost::vecS, boost::vecS,boost::directedS, boost::no_property, edgeProperties>;
void initializeGraph(Graph &g, Graph::vertex_descriptor &start, Graph::vertex_descriptor &end, std::ifstream &fin)
// Initialize g using data from fin. Set start and end equal to the start and end nodes.
{
edgeProperties e;
int n, i, j;
int startId, endId;
fin >> n;
fin >> startId >> endId;
Graph::vertex_descriptor v;
// Add nodes.
for (int i = 0; i < n; i++) {
v = add_vertex(g);
if (i == startId)
start = v;
if (i == endId)
end = v;
}
while (fin.peek() != '.' && fin >> i >> j >> e.weight) {
add_edge(i, j, e, g);
}
}
#include <boost/graph/graph_utility.hpp>
int main() {
std::ifstream infile("input.txt");
Graph g;
Graph::vertex_descriptor start, end/*, curr*/;
initializeGraph(g, start, end, infile);
print_graph(g);
}
for Input.txt:
5
0 4
2 3 1
1 2 1
3 4 1
0 2 1
.
打印:
0 --> 2
1 --> 2
2 --> 3
3 --> 4
4 -->
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- "no matching function for call to 'Vector::Vector'"错误
- 我在 ifstream input_file(文件名)行中收到错误"no matching function to call";
- 模板规范获取'Ambiguous call to overloaded function'
- 从 TVector2 类派生复杂类:"No matching function for call to Complex::Complex()"
- 结构错误:"no matching function for call to "
- C++线程"Call to non-static member function without an object argument"
- 如果子类中没有构造函数方法,则错误"no matching function for call to 'LGame::LGame(String&)'"
- "error: no matching function for call to",我无法更改结构的定义
- 如何修复以下错误"no match for call to '(std::tr1::shared_ptr<_iobuf*>) (FILE*&)'"
- 替换派生对象向量中的对象"no matching function to call"
- 我的程序显示许多错误,"error: no matching function for call to 'getPercentScore'"
- "How to make a recursive call for palindrom numbers without reverse function in c++?"
- add_edge导致"no function to call error"
- 如何修复C++中的"no matching function to call to..."?
- 调用布尔函数但收到错误"no matching function to call"?
- C++ 错误:使用 argc、*argv[] 和多维数组调用 void 函数时"no matching function to call to "
- "No matching functions to call to"发生在C++的构造函数上
- 构造函数模板调用'no matching function to call'