Skip to main content
added 167 characters in body
Source Link
justyy
  • 6k
  • 4
  • 41
  • 81

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays

You can also initialise the 'arrays', just give it a default value

const int DEFAULT = 1234;
vector< vector<int> > f(rows, vector<int>(cols, DEFAULT));

Source: How to Create 2, 3 (or Multi) Dimensional Arrays in C/C++?

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays

Source: How to Create 2, 3 (or Multi) Dimensional Arrays in C/C++?

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays

You can also initialise the 'arrays', just give it a default value

const int DEFAULT = 1234;
vector< vector<int> > f(rows, vector<int>(cols, DEFAULT));

Source: How to Create 2, 3 (or Multi) Dimensional Arrays in C/C++?

added 148 characters in body
Source Link
justyy
  • 6k
  • 4
  • 41
  • 81

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays

Source: How to Create 2, 3 (or Multi) Dimensional Arrays in C/C++?

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays

Source: How to Create 2, 3 (or Multi) Dimensional Arrays in C/C++?

Source Link
justyy
  • 6k
  • 4
  • 41
  • 81

Why not use STL:vector? So easy, and you don't need to delete the vector.

int rows = 100;
int cols = 200;
vector< vector<int> > f(rows, vector<int>(cols));
f[rows - 1][cols - 1] = 0; // use it like arrays