how to declare a 2d boolean vector in c++

#include <iostream>
#include <vector>

int main() {
    int rows = 3; // Define the number of rows
    int cols = 4; // Define the number of columns

    std::vector<std::vector<bool>> matrix(rows, std::vector<bool>(cols, false)); // Declare a 2D boolean vector with initial values set to false

    // Accessing and modifying elements in the boolean vector
    matrix[0][1] = true; // Setting a specific element to true

    // Printing the boolean vector
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            std::cout << matrix[i][j] << " "; // Output the elements
        }
        std::cout << std::endl; // Move to the next row
    }

    return 0;
}