How solve the error on multi-D dynamic array read to be output below?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
#include <vector>
using namespace std;
vector<vector<char>> l;
l[0].push_back('f');
l[0].push_back('o');
l[0].push_back('o');
l[1].push_back('b');
l[1].push_back('a');
l[1].push_back('r');
l[2].push_back('b');
l[2].push_back('a');
l[2].push_back('z');
for( auto i: l) {
cout << i[2] <<endl;
}
|
to get third element of each inner array by that declaration (must not changed to
vector<char> l[3] )
Last edited on