I don't see what the fuss is about BOOL/bool.
It's totally "legal" and it's easier to use. (0 and 1 ranther than 'M' and 'F')
I don't see what the fuss is about BOOL/bool.
It's totally "legal" and it's easier to use. (0 and 1 ranther than 'M' and 'F')
I agree.
"The Internet treats censorship as damage and routes around it." - John Gilmore
We aren't comparing it to 'M' and 'F' we're comparing it to an enum. And I think we've given plenty of reasons why an enum is better.Originally Posted by Queatrix
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
It's the question of attitude. You can't say enum is better, you can say that you like enum more.
"The Internet treats censorship as damage and routes around it." - John Gilmore
It's not about liking anything better, it's about choosing the right tool for the job. You could hang a picture with a sledge hammer, but you might also knock the wall down. enum is clearer: how are you supposed to remember that true is male and false is female? Compare that to just giving a constant a label.
Just reminding:
This IS the question of attitude. It is like if you like apple or banana more.Code:#define MALE false #define FEMALE true
"The Internet treats censorship as damage and routes around it." - John Gilmore
That has little association with a property of humans at all. Since we're bringing in C, we might as well take it all the way. Your way will work, but so will this:
Keep things encapsulated.Code:if( strcmp(this, that) == MALE ) puts("omgz");
That's been causing errors for many beginners, they add a line and don't understand the mistake . Then they come to these forums and post their code.
"The Internet treats censorship as damage and routes around it." - John Gilmore
So you're saying that the result of two equal strings can be male? You missed my point completely, and I'm done with this thread.
I was talking about your encapsulating thing.
"The Internet treats censorship as damage and routes around it." - John Gilmore
Wow, this got way off topic lol.
Well, I got the answers I needed out of it. Thanks for the help guys.
Code:/* ------------------------------------------------------------------*/ // INSERT CODE HERE /* ------------------------------------------------------------------*/
here's why bool is completely and utterly wrong for specifying gender:
how do you specify a hermaphrodite with a bool? They do exist and are neither exclusivly male or female. With a bool you're screwed. with an enum you can add another value and away you go.
the point is that bools are designed to handle BOOLEAN state (on or off, 1 or 0, true or false) Enums are designed to handle an CONSTANT ENUMERATED SET OF VALUES (Days of the week, Months of the year, Known error conditions). If a particular set of values comprises only 2 possible values that does not make it a bool!
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?
But you gotta admit it's been damned entertaining this far.
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}