我試了發現所有都是ture 輸入非布爾值也是
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void)
{
cout<<"請輸入一個整數:"<<endl;
int x=0;
cin>>x;
cout<<oct<<x<<endl;
cout<<dec<<x<<endl;
cout<<hex<<x<<endl;
cout<<"請輸入一個布爾值(0,1):"<<endl;
bool y=false;
cin>> y;
cout<<boolalpha<<y<<endl;
system("pause");
return 0;
}
2019-05-05
然鵝vs2010就是個反例。。。估計是編譯器的問題。。
2017-03-03
其實對于bool而言非0就是true