Okay, in chap 7.6 "type definitions" it says "there's a better way to set up a Boolean type, though, using a feature known as a type definition.
typedef int Bool;
So, I didn't exactly remember what a Boolean was all about so I went back to chapter 5.2 to look again. (There is only 1 page about Boolean) I've not had to use it in any of the exercises thus far. (I've done them all up to now)
This is all it says about Boolean Values:
Book: "C's lack of a proper Boolean type can be annoying, since many programmers need variables that can store either false or true. (Recognizing this problem, newer versions of C++ provide a built in Boolean type) We can always simulate a Boolean variable by declaring an int variable then assigning it 0 or 1."
That's the entire explanation of Boolean values. Of course, chapter 7 says, "there's a better way to set up a Boolean type" which discredits what it already taught me in chapter 5.2, if there's a better way why did they teach me the worse way first?? ARGH!
Based on the above, I guess a Boolean value is just a variable that can store either 1 or 0, (true or false). But I don't understand why I'd need to do that? Or when?
So what is the point of a Boolean value? How and when and why is it used? Unless I'm missing something, I don't really think that paragraph taught me about Boolean values in enough detail.
So now in Ch 7, I'm learning a better way to set up a Boolean Value, which is something that they really haven't taught me to use in the first place. Am I missing something here?
typedef int Bool;
So, I didn't exactly remember what a Boolean was all about so I went back to chapter 5.2 to look again. (There is only 1 page about Boolean) I've not had to use it in any of the exercises thus far. (I've done them all up to now)
This is all it says about Boolean Values:
Book: "C's lack of a proper Boolean type can be annoying, since many programmers need variables that can store either false or true. (Recognizing this problem, newer versions of C++ provide a built in Boolean type) We can always simulate a Boolean variable by declaring an int variable then assigning it 0 or 1."
That's the entire explanation of Boolean values. Of course, chapter 7 says, "there's a better way to set up a Boolean type" which discredits what it already taught me in chapter 5.2, if there's a better way why did they teach me the worse way first?? ARGH!
Based on the above, I guess a Boolean value is just a variable that can store either 1 or 0, (true or false). But I don't understand why I'd need to do that? Or when?
So what is the point of a Boolean value? How and when and why is it used? Unless I'm missing something, I don't really think that paragraph taught me about Boolean values in enough detail.
So now in Ch 7, I'm learning a better way to set up a Boolean Value, which is something that they really haven't taught me to use in the first place. Am I missing something here?