'I'm trying to create a 2D vector to which i can append values easily

In my head it seems like creating (a) vector by pushing n number of elements and then appending the (a) vector to the (b) vector to make a 2D vector. I'm still a rookie at C++ so can someone suggest me a better idea

#include <iostream>
#include<vector>
using namespace std;
int main() {
    int numOfIter;
    vector <int> a;
    vector <int> b;
    cout << "enter the number of iterations -> ";
    cin >> numOfIter;
    for(int i = 0; i < numOfIter; i++){
        a.push_back(i);
    }
    b.push_back(a);

    for(int it : b){
        cout << it;   
    }
    return 0;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source