我试图创建一个结构的向量。我在创建带有结构的向量时遇到了一些问题。向量的结构
这里的错误消息:
testt.cpp: In constructor 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Al
loc>::size_type, const value_type&, const allocator_type&) [with _Tp = flowPath;
_Alloc = std::allocator<flowPath>; std::vector<_Tp, _Alloc>::size_type = unsign
ed int; std::vector<_Tp, _Alloc>::value_type = flowPath; std::vector<_Tp, _Alloc
>::allocator_type = std::allocator<flowPath>]':
testt.cpp:20:28: error: no matching function for call to 'flowPath::flowPath()'
testt.cpp:20:28: note: candidates are:
testt.cpp:10:5: note: flowPath::flowPath(int)
testt.cpp:10:5: note: candidate expects 1 argument, 0 provided
testt.cpp:5:8: note: flowPath::flowPath(const flowPath&)
testt.cpp:5:8: note: candidate expects 1 argument, 0 provided
下面的代码:
#include <vector>
#include "FlowGraph.cpp"
using namespace std;
struct flowPath {
int vertex;
Edge *edge;
Edge *res;
flowPath(int v){
vertex = v;
}
};
void bfs(vector<flowPath>& parentPath){
//Stuffs
}
int main(void) {
vector<flowPath> path(5);
bfs(path);
return 0;
}
我没有得到一半的错误,我尝试了谷歌的东西,但失败了.. 。 提前致谢!
'VECTOR'需要的类型('flowpath') – Ajay
通知了'错误默认的构造函数:'一部分。地点和笔记后来。 – LogicStuff
我有一个构造函数,flowpath(int v){}? – Sakutard