resize 2d vector c++

#include <iostream>
#include <vector>

int main() {
    // Step 1: Define a 2D vector
    std::vector<std::vector<int>> myVector;

    // Step 2: Define the dimensions of the 2D vector
    int numRows = 3;  // Number of rows
    int numCols = 4;  // Number of columns

    // Step 3: Resize the 2D vector with the specified dimensions
    myVector.resize(numRows, std::vector<int>(numCols));

    // Step 4: Access and modify elements in the 2D vector
    myVector[1][2] = 42;

    // Step 5: Display the elements of the 2D vector
    for (int i = 0; i < numRows; ++i) {
        for (int j = 0; j < numCols; ++j) {
            std::cout << myVector[i][j] << " ";
        }
        std::cout << std::endl;
    }

    return 0;
}