I was just wondering, why wasn't the bool type built-in to C++? That seems like it would've been a good idea.
Printable View
I was just wondering, why wasn't the bool type built-in to C++? That seems like it would've been a good idea.
It is AFAIK.
It is. It wasn't in C, however.
Huh? What does that mean?Quote:
It is AFAIK.
Really? Then why does my compiler give me an error whenever I use bool without including "bool.h"?Quote:
It is. It wasn't in C, however.
Because you are probably using a C compiler.
EDIT: Or perhaps a REALLY old C++ compiler?
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?
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.Quote:
Originally posted by Polymorphic OOP
Yeah, most likely. You're best off getting a new compiler.
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 variables:rolleyes:Code:#ifndef BOOL_H
#define BOOL_H
#undef true
#undef false
const int true = 1;
const int false = 0;
typedef int bool;
#endif
yeah, i learned true as 1 and false as 0, binary...Quote:
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. :D 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
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