C++_bool

1 0

 1 #include <iostream>
 2 using namespace std;
 3 
 4 void main()
 5 {
 6     bool bl = 1 && 1 || 2 || -1 && 0;
 7 
 8     std::cout << bl << std::endl;//1
 9 
10     std::cout << typeid(bl).name() << std::endl;//bool,获取变量bl的数据类型
11 
12     decltype (bl) newbl(1 + 2 * 3 - 4 && 3 + 2 || -1);//根据变量bl,创建一个相同类型的新变量newbl
13 
14     std::cout << newbl << std::endl;//1
15 
16     system("pause");
17 }
原文地址:https://www.cnblogs.com/denggelin/p/5648523.html