Professional Documents
Culture Documents
ЛР-1 - Bodnar - Danylo - ОІ-16 копія
ЛР-1 - Bodnar - Danylo - ОІ-16 копія
Звіт
до лабораторної роботи № 2
з дисципліни
Об’єктно-орієнтоване програмування
на тему:
“Робота з динамічною пам’яттю. Перевантаження операцій
С++ ”
Боднар Данило
Прийняла:
Ткачук К. I.
Львів – 2023
Лабораторна робота №2
Послідовність роботи:
Індивідуальне завдання:
class Matrix
{
private:
int rows;
int columns;
int **twoDimensionalArray;
public:
Matrix()
{
}
Matrix(int r, int c)
{
rows = r;
columns = c;
twoDimensionalArray = new int *[rows];
return resultMatrix;
}
Matrix operator-(const Matrix &secondMatrix)
{
if (rows != secondMatrix.rows || columns != secondMatrix.columns)
{
throw invalid_argument("Matrices must be of the same size.");
}
return resultMatrix;
}
Matrix operator*(const Matrix &secondMatrix)
{
if (columns != secondMatrix.rows)
{
throw invalid_argument("Matrices must be columns != secondMatrix.rows.");
}
return resultMatrix;
}
Matrix &operator=(const Matrix &otherMatrix)
{
this->rows = otherMatrix.rows;
this->columns = otherMatrix.columns;
this->twoDimensionalArray = new int *[rows];
delete[] twoDimensionalArray;
}
};
int main()
{
int amountOfMatrices = 6;
Matrix *matrices[amountOfMatrices];
printMatrices(matrices, amountOfMatrices);
insertionSort(matrices, amountOfMatrices);
return 0;
}
*arr[j + 1] = key;
}
printMatrices(arr, size);
}
Результат роботи:
Висновок