Проблема: ошибка при транспонировании динамического двумерного массива.
#include <ctime>
#include <string>
#include <iostream>
using namespace std;
---------------------------
class Array
{
public:
Array(int ROWS,int COLS) {
this->ROWS = ROWS;
this->COLS = COLS;
arr = new int*[ROWS];
for (int i = 0; i < ROWS; i++)
{
arr[i] = new int[COLS];
}
for (int i = 0; i < ROWS; i++)
{
for (int j = 0; j < COLS; j++)
{
arr[i][j] = rand() % 10 + 100;
cout << arr[i][j] << "\t";
}
cout << endl;
}
};
------------------
Array(const Array& other) {
this->ROWS = other.ROWS;
this->COLS = other.COLS;
this->arr = new int* [other.ROWS];
for (int i = 0; i < other.ROWS; i++)
{
this->arr[i] = new int[other.COLS];
}
cout << endl;
for (int i = 0; i < other.ROWS; i++)
{
for (int j = 0; j < other.COLS; j++)
{
this->arr[j][i] = other.arr[i][j];
cout << this->arr[j][i] << "\t";
}
cout << endl;
}
}
private:
int ROWS;
int COLS;
int **arr;
};
void main()
{
setlocale(LC_ALL, "ru");
srand(time(NULL));
Array a(2, 4);
Array b(a);
system("pause");
}