获取函数返回值
比如
bool getvalue(bool b){
if(b == true)
return true;
else
return false;
}int main(){
//在main()中调用函数就可以得到函数的返回结果
cout<<boolalpha<<getValue(true);
return 0;
}
bool像int类型一样,只是它的取值只能的true,或false,代表逻辑真或逻辑假
示例如下:
#include<iostream>
using namespace std;
int main(){
cout<<"2>3="<<boolalpha<<(bool)(2>3)<<endl;
return 0;
}
运行截图
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/79f0f736afc3793198eed6c3e9c4b74542a91151?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)