initializing vector of vectors c++ code example
Example 1: initializing 2d vector
vector<vector<int> > vec( n , vector<int> (m, 0));
Example 2: initialising 2d vector
// Initializing 2D vector "vect" with
// values
vector<vector<int> > vect{ { 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 } };
Example 3: c++ initialize a vector
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main()
{
// This vector initializes with the values: 10, 20, and 30
vector<int> vect{ 10, 20, 30 };
return 0;
}