警告「制御が空でない関数の終了に達しました」という警告を出したとき、どうすればよいですか? 私のオーバーロードされた演算子はtryとcatchを持ち、returns *this ;
はtryスコープにあります。私は、Eclipseを使用してい試してキャッチしたときのC++の戻り値
は、G ++コンパイラ、UbuntuのLinuxのある
NNmatrix & operator*=(const NNmatrix<T> &mtrxB)
{
// A=2*3 B=3*4 return C=2*4
const UINT aRows = this->size1();
const UINT aCols = this->size2();
const UINT bRows = mtrxB.size1();
const UINT bCols = mtrxB.size2();
try
{
// if cols of first(this) matrix == rows of second matrix
if (aCols != bRows) throw bad_alloc();
const UINT cRows = aRows;// = rows of first matrix
const UINT cCols = bCols; // = cols of second matrix
NNmatrix mtrxC(cRows, cCols);
T val;
for (UINT i = 0; i < cRows; i++)
{
for (UINT j = 0; j < cCols; j++)
{
val = 0;
for (UINT k = 0; k < bRows; k++)
{
val += this->matrix.at(i).at(k) * mtrxB.getElement(k, j);
}
mtrxC.setElement(i, j, val);
}
}
*this = mtrxC;
mtrxC.clear();
return *this;
}
catch (exception& e)
{
cout<<"Dimension don't match: ("<<aRows<<","<<aCols<<") ("<<bRows<<","<<bCols<<")"<<endl;
}
}
コードを投稿してください(使用しているコンパイラは何ですか)。 – egrunin
警告を修正する必要があります。今、あなたの問題を示す例がありますか? –
あなたのコードを投稿してください、私はあなたから質問の問題のあいまいなアイデアを得るだけです。 –