I am new to C++ (and quite new to programming overall) and I was reading my C++ college book ("Starting out with C++ Early Objects" 9th edition by Gaddis, Walters and Muganda) when I came across a note on the bool data type.
"NOTE: Notice that true and false do not have quotation marks around them. This is because they are variables, not strings."
Now, from what I've learned, variables can be changed. I understand that a variable of the bool data type would be a variable, but how come true
and false
are considered variables?
From my understanding, false
is stored as an integer value 0
and true
as an integer value 1
. I tried assigning values x
where x
is 0<x<0
to a bool and they all output 1
which made me come to the conclusion that true
is also everything other than 0
(in other words, true is the same as !false
?).
So if this is true, how come 'false' is considered a variable and not a constant?