bool y如果輸入其他數(shù)字為什么一概為false?不是說非零就為true嗎?
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(void)
{
int x=0;
cout<<"Please input a integer:";
cin>>x;
cout<<oct<<x<<endl;
cout<<dec<<x<<endl;
cout<<hex<<x<<endl;
cout<<"Please input a bool:";
bool y=false;
cin>>y;
cout<< boolalpha << y << endl;
system("pause");
return 0;
}
2016-07-13
你看錯了吧,我試過你的代碼了。。完全沒問題
2016-08-29
我也出現(xiàn)了這個問題啊,其他數(shù)字都是false,求教~
2016-07-13
輸入非0數(shù)字 結(jié)果是true