samedi 27 avril 2019

How to do constructor for 2D vector in C++?

I tried initializing a 2D vector with a constructor in 3 different ways but always get an

"error: no matching function to call"

Could you tell me where I am wrong?

class Node 
{
public:
  int to;
  int length;
  Node(int to, int length) : to(to), length(length){}
};

class Graph 
{
public:
  vector<vector<Node>> nodes_list;
  int n;
  Graph();
};

Graph::Graph(){
  nodes_list = vector<vector<Node> >(n, vector<Node>(n,0x3fffffff));
}

Aucun commentaire:

Enregistrer un commentaire