|
第二章 数据类型 上机实践 31页的 2
输入如下代码:
#include<iostream.h>
int main(void)
{
bool b;
bool a;
cin>>a;
cin>>b;
cout<<"!a="<<!a<<endl;
cout<<"a&&b : "<<(a&&b)<<endl;
cout<<"a||b :"<<(a||b)<<endl;
return 0;
}
但编译出来的时候,却显示如下错误:
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'bool' (or there is no acceptable conversion)
: error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'bool' (or there is no acceptable conversion)
执行 cl.exe 时出错.
这是为什么呢?bool 型数据不能 接受 键盘输入 到cin? |
|