#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Node1 {
unsigned int vertex;
unsigned int representative;
Node1(unsigned int Vert, unsigned int Rep) : vertex(Vert), representative(Rep) {}
};
class Graph{
vector<Node1> nodes;
public:
void findComponents() {
nodes.emplace_back(1, 1);
nodes.resize(1);
// nodes.resize(newSize);
}
};
int main(){
Graph g;
g.findComponents();
}
我收到大量奇怪的构建错误,主要由“候选构造函数不可行”和“在实例化成员函数'std :: __ 1 :: vector> :: resize'中请求她”组成
要使用下面vector::resize()
在代码中使用的重载,T
必须满足MoveInsertable和DefaultInsertable的要求。
void resize( size_type count );
DefaultInsertable表示该类型的实例可以就地默认构造。
因此,您需要的是一个默认构造函数Node1
。为此,您可以执行以下操作:
Node1() = default;
或者指定的默认值Vert
,并Rep
在这样现有的构造函数:
Node1(unsigned int Vert = 0, unsigned int Rep = 0) : vertex(Vert), representative(Rep) {}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句