64,676
社区成员
发帖
与我相关
我的任务
分享
bool function (ElemType1 p1,ElemType p2); // 比如有这样一个bool函数,实际的返回值是整型数字
//...
int main() // 将问题简化一下,在主函数里调用function函数,并把返回值赋给变量result
{
bool result = function(p1, p2);
if( result != false ) // 为什么这样的写法比较稳妥?
{
//...
}
// if( result == true ) 请问这样写为什么不如上面的写法更稳妥?
}
if(result) ...
if(!result) ...
bool result; //只可能为true或false
if(result)
{
//sth
}
//or
if(!result)
{
//sth
}
这样不是很简单 if( result ) //难道这样不是既稳妥又简洁而且还更高效吗?