Matrix operator+(Matrix &a1, Matrix &a2)
{
Matrix temp;
temp = a1;
for (int i = 0; i < a1.row; i++)
for (int j = 0; j < a1.col; j++)
temp.a[i][j] = a1.a[i][j] + a2.a[i][j];
return temp;
}
我想請問下,for循環不加大括號和加大括號的區別,不是很明確
感謝!
Matrix operator+(Matrix &a1, Matrix &a2)
{
Matrix temp;
temp = a1;
for (int i = 0; i < a1.row; i++)
{
for (int j = 0; j < a1.col; j++)
{
temp.a[i][j] = a1.a[i][j] + a2.a[i][j];
}
}
return temp;
}
是這樣寫的麼?