1 #include <iostream> 2 using namespace std; 3 4 int main(void){ 5 bool b = false; 6 cout << b << endl;//0 7 //插入流控制符boolalpha,以字符串形式打印bool 8 cout << boolalpha << b << endl;//false 9 10 return 0; 11 } 运行之后 ~ tarena@ubuntu:~/cplus/day01$ g++ 10bool.cpp tarena@ubuntu:~/cplus/day01$ ./a.out 0 false |
|