📜  空 2d 数组作为类 c++ 代码示例的成员

📅  最后修改于: 2022-03-11 14:44:51.521000             🧑  作者: Mango

代码示例1
class Screen {
    private:
        char **data;
        int rows;
        int columns;

    public:
        Screen(int num_rows, int num_cols); 
}; 

Screen::Screen(int num_rows, int num_cols) {
    data = new char * [num_rows];
    for (int i = 0; i < num_rows; ++i) {
        data[i] = new char[num_cols];
    }
    rows = num_rows;
    columns = num_cols;
}