I was just wondering, why wasn't the bool type built-in to C++? That seems like it would've been a good idea.
I was just wondering, why wasn't the bool type built-in to C++? That seems like it would've been a good idea.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
It is AFAIK.
It is. It wasn't in C, however.
Huh? What does that mean?It is AFAIK.
Really? Then why does my compiler give me an error whenever I use bool without including "bool.h"?It is. It wasn't in C, however.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
Because you are probably using a C compiler.
EDIT: Or perhaps a REALLY old C++ compiler?
Last edited by Polymorphic OOP; 01-06-2003 at 10:56 PM.
As Far As I Know...
What compiler are you using? I think bool is somewhat new.
The copyrights on the compiler I use at home, MPW, are from 1985-1999. Is that the problem, then?
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
Yeah, most likely. You're best off getting a new compiler.
I'd like to, but MPW is the only free compiler available for Macs. Oh well. I'm hopefully *crosses fingers* getting a new computer soon. In that case, I'll run Linux on it, and I believe that Linux comes with gcc.Originally posted by Polymorphic OOP
Yeah, most likely. You're best off getting a new compiler.
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
You can always define your own bool type Some people will tell you to define true as 1 and false as 0. I don't know about that, this is how I do it.
Code:#define true ( 5 == 5 ) #define false ( !true ) typedef int bool;
Thanks, but I already have a header file for bool:
I was just complaining cuz I hafta include that in every program I write that uses boolean variablesCode:#ifndef BOOL_H #define BOOL_H #undef true #undef false const int true = 1; const int false = 0; typedef int bool; #endif
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
yeah, i learned true as 1 and false as 0, binary...Originally posted by MrWizard
You can always define your own bool type Some people will tell you to define true as 1 and false as 0. I don't know about that, this is how I do it.
Code:#define true ( 5 == 5 ) #define false ( !true ) typedef int bool;
you could do it that way, or another way, (I think this is right)
I'm not sure if that is how you implement an enumerated type, not sure on syntax, I haven't worked with enum that much.Code:enum bool { false, true };
You might also try checking for updates to MPW.
Here's a link I found to apple.com that allows for downloading it. And the file is dated 2001.
ftp://ftp.apple.com/developer/Tool_C...MPW-GM_Images/
As for compilers... I even found a C compiler for the old Commodore computers. http://www.cc65.org/
Just return 1 for true and 0 for false, I think that is what a bool type would do anyway it would just be masked with words, or you could define them.
Thats has always worked for me and I am using a very old compiler.Code:#define FALSE 0 #define TRUE !FALSE
Compiler == Visual C++ 6.0"Come Out Fighting."
Just return 1 for true and 0 for false, I think that is what a bool type would do anyway it would just be masked with words, or you could define them.
Thats has always worked for me and I am using a very old compiler.Code:#define FALSE 0 #define TRUE !FALSE
Compiler == Visual C++ 6.0"Come Out Fighting."