Please tell me where my mistake is. I implemented a class with a two-dimensional dynamic array. The number of columns and fields is set through the constructor. The problem occurs when I try to overload the input operator in a similar way:
friend IntArr& operator >> (istream &in, IntArr& a) { for (int i = 0; i < a.rows; i++) { for (int j = 0; j < a.cols; j++) { in >> a.pa[i][j]; } } return in; } Here is the class itself:
class IntArr { friend IntArr& operator >> (istream &in, IntArr& a) { for (int i = 0; i < a.rows; i++) { for (int j = 0; j < a.cols; j++) { in >> a.pa[i][j]; } } return in; } private: int **pa; int rows, cols; public: IntArr() { pa = 0; rows = 0; cols = 0; } IntArr(int rows, int cols) { this->rows = rows; this->cols = cols; float **pa = new float*[this->rows]; // две строки for (int count = 0; count < 2; count++) pa[count] = new float[this->cols]; // и пять столбцов } };