Chaining Bool values give opposite result to expected
问题 Unthinkingly I wrote some code to check that all the values of a struct were set to 0. To accomplish this I used: bool IsValid() { return !(0 == year == month == day == hour == minute == second); } where all struct members were of type unsigned short. I used the code as part of a larger test but noticed that it was returning false for values differing from zero, and true for values that were all equal to zero - the opposite of what I expected. I changed the code to read: bool IsValid() {