2D Vectors
A vector of vectors makes a grid.
Example
#include <iostream>
#include <vector>
int main() {
std::vector<std::vector<int>> g(2, std::vector<int>(3, 0));
g[1][2] = 7;
for (auto &row : g) { for (int x : row) std::cout << x << " "; std::cout << "\n"; }
return 0;
}Result
0 0 0 0 0 7
Exercise
Rows count.
g.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.