Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

empty 2d array as a member of a class class c++

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #empty #array #member #class #class
ADD COMMENT
Topic
Name
5+2 =