Making a human class...not sure what to do

This is a discussion on Making a human class...not sure what to do within the C++ Programming forums, part of the General Programming Boards category; I don't see what the fuss is about BOOL/bool. It's totally "legal" and it's easier to use. (0 and 1 ...

  1. #31
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    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')

  2. #32
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I agree.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  3. #33
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Quote Originally Posted by Queatrix
    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')
    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.
    "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

  4. #34
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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

  5. #35
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,622
    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.

  6. #36
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Just reminding:
    Code:
    #define MALE false
    #define FEMALE true
    This IS the question of attitude. It is like if you like apple or banana more.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #37
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,622
    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:
    Code:
    if( strcmp(this, that) == MALE )
        puts("omgz");
    Keep things encapsulated.

  8. #38
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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

  9. #39
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,622
    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.

  10. #40
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I was talking about your encapsulating thing.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  11. #41
    Codigious FingerPrint's Avatar
    Join Date
    Mar 2006
    Posts
    60
    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
    /* ------------------------------------------------------------------*/

  12. #42
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    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?

  13. #43
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    This thread is stupid.

  14. #44
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    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;}

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 04:01 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21