I'm writing this copy constructor:
//CCtor of RegMatrix
RegMatrix::RegMatrix(const RegMatrix &other){
this-> numRow = other.getRow();
this-> numCol = other.getCol();
//Create
_matrix = createMatrix(other.numRow,other.numCol);
int i,j;
//Copy Matrix
for(i=0;i<numRow; ++i){
for(j=0;j<numCol; ++j){
_matrix[i][j] = other._matrix[i][j];
}
}
}
Is there a problem to initialize numRow, numCol in the initialization list like this: numRow(other.numRow), numCol(other.numCol)
instead of:
this-> numRow = other.getRow();
this-> numCol = other.getCol();
Also, i don't know if there isn't such a problem, is there a problem of calling other classes' object's function in the initialization list, such as:
numRow(other.getRow())
instead of:
this-> numRow = other.getRow();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…