我有Mtx
在矩阵之间做一些计算
Mtx M1(rows1,cols1,1); //instantiate data members and fill the matrix with 1s
Mtx M2(rows2,cols2,2); //instantiate data members and fill the matrix with 2s
Mtx M3(rows3,cols3,0); //instantiate data members and fill the matrix with 0s
M3 += M1; //+= is overloaded - First M3
M3 -= M2; //-= is overloaded - Second M3
第一个M3
用M3
零填充并将其添加到M1
,答案将分配给M3
. 我这里没有问题。
问题出在第二个M3
!它不会减去M3
用零填充的值,而是使用前一个操作的结果并将其从M2
.
我怎样才能使M3
静态保持其价值?它与静态对象有关吗?我希望你明白我的意思!
感谢您的帮助...