When I write that x is 3 I thus exceeded expectations because I did not write a zero or a 1 but nevertheless this non-zero value is implicitly converted into a Boolean value so ouput is 1.
#include <iostream>
using namespace std;
int main() {
bool x;
cin>>x;
cout << x<< "\n";
return 0;
}
When I write that x is text hallo I thus exceeded expectations because I did not write a zero or a 1 but in this case this non-zero value is not implicitly converted into a Boolean value so output is 0 Isn't it supposed this text hallo is converted to boolean value so output is 1.
It is assumed that the output will be 1 because the text value hallo is converted to boolean value so output is 1. So if you told me that the cin >>
expects from the beginning to enter a value of zero or one .. then you violated the expectations, so the output is zero. I will reply to you and say that when I entered that the value of x is 3, I also violated expectations because I was supposed to enter a value of one or zero, and yet the output was one, so why did this not happen when I entered the text value and why was it not implicitly converted to a boolean value