Byr*_*ron 2 c++ warnings loops return
我有一个if ... else语句,当我编译时,我收到警告"并非所有控制路径都返回一个值".谁能告诉我为什么我会收到这个警告?
我的代码:
template<typename T>
double NumericArray<T>::Dot(const NumericArray& na)
{
if (Size() == na.Size())
{
double result = 0;
for (int i=0; i<Size(); i++)
{
result += ((na.GetElement(i))*(GetElement(i)));
}
return result;
}
else
{
cout<<"Error! Dot Product Operands Number Of Elements Unequal"<<endl;
}
}
Run Code Online (Sandbox Code Playgroud)
我没有看到通过我的代码可以达到除定义结果之外的任何其他内容.
谢谢.
归档时间: |
|
查看次数: |
232 次 |
最近记录: |