Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Matrix& operator=(const Matrix& matr);//Оператор присваивания
- Matrix(const Matrix &matr); //Конструктор копирования
- Matrix::Matrix(const Matrix &matr){//Конструктор копирования
- m_rows = matr.m_rows;
- m_cols = matr.m_cols;
- m_matrix = new int*[m_rows];
- for (int i = 0; i < m_rows; i++)
- m_matrix[i] = new int[m_cols];
- for (int i = 0; i < m_rows; i++)
- for (int j = 0; j < m_cols; j++)
- m_matrix[i][j] = matr.m_matrix[i][j];
- }
- Matrix& Matrix::operator = (const Matrix& matr){//Оператор присваивания
- if (&matr == this){
- }else{
- m_rows = matr.m_rows;
- m_cols = matr.m_cols;
- m_matrix = new int*[m_rows];
- for (int i = 0; i < m_rows; i++)
- m_matrix[i] = new int[m_cols];
- for (int i = 0; i < m_rows; i++)
- for (int j = 0; j < m_cols; j++)
- m_matrix[i][j] = matr.m_matrix[i][j];
- }
- return *this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement