#include <iostream>
using std::cout;
using std::endl;
int main()
{
bool b = false;
cout << "b = " << b << endl; // 0
cout << "++b = " << ++b << endl; // warning: deprecated, displays 1
cout << "++b = " << ++b << endl; // warning: deprecated, still 1
// cout << "--b = " << --b << endl; // compile error
b = 2; // no warning
cout << "b = " << b << endl; // still 1
b = -1; // no warning
cout << "b = " << b << endl; // still 1
cout << "++b = " << ++b << endl; // warning: deprecated, prints 1
return 0;
}
/*
g++ Bool.cpp -o Bool
./Bool
b = 0
++b = 1
++b = 1
b = 1
b = 1
++b = 1
*/
Comments
Post a Comment