用boolalpha输出true或false的问题
为什么用了boolalpha之后的所有输出会全是true或是false,即使之后的输出行没有用boolalpha
#include <iostream>
using namespace std;
int main()
{
bool b=true;
cout << "b=" << b << endl;
b = false;
cout << "b=" << b << endl;
cout << "b=" << boolalpha << b << endl;
cout << b << endl;
bool a = true;
cout << "a = " << a << endl;
}
输出结果:
b=1
b=0
b=false
false
using namespace std;
int main()
{
bool b=true;
cout << "b=" << b << endl;
b = false;
cout << "b=" << b << endl;
cout << "b=" << boolalpha << b << endl;
cout << b << endl;
bool a = true;
cout << "a = " << a << endl;
}
输出结果:
b=1
b=0
b=false
false
a = true