Created
April 15, 2009 06:56
-
-
Save khafatech/95655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy constructor | |
Matrix::Matrix(const Matrix &rhs) | |
{ | |
if (this != &rhs) { | |
// newly created object | |
this->a = NULL; | |
// copy rhs to this | |
*this = rhs; | |
} | |
} | |
// This actually does the copying | |
// If this is a new object, a is set to NULL | |
Matrix& Matrix::operator =(const Matrix &m) | |
{ | |
if (this != &m) { | |
if(this->a != NULL) delete [] a; | |
this->x = m.x; | |
this->y = m.y; | |
this->k = m.k; | |
this->a = new Ratio[k]; | |
for(int i = 0; i < k; i++) | |
this->a[i] = m.a[i]; | |
} | |
return *this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment