Help on an enum statement

This is a discussion on Help on an enum statement within the C++ Programming forums, part of the General Programming Boards category; hi! when you declare a enumerated data type such as enum speeds {slow, med, fast}; slow takes onthe value 0, ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    38

    Help on an enum statement

    hi!
    when you declare a enumerated data type such as

    enum speeds {slow, med, fast};

    slow takes onthe value 0, then 1, 2. But when you write the statement like this:

    enum speeds {slow=1, med, fast}

    the order now starts - 1, 2, 3.

    so my question is this; if you have a enum type liek this:

    enum speeds {slow=78, med = 45, fast = 33}:

    then internally does the compiler think it's 78, 79, 80, or because all are initilized does it put them as 0, 1, 2 still? Thanks
    #include <Jesus.h>
    It will save your life

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    nope they have the values you assigned them. 78,45,33.

    btw they r wrong way round. record speeds were slowest to fastest 16/33/45/78.
    dont think 16rpm speed records were made after about 1950.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  2. enum switchcase and windows message q
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 11-27-2006, 12:16 PM
  3. Switch case and enum help
    By SomeCrazyGuy in forum C++ Programming
    Replies: 9
    Last Post: 04-21-2005, 08:53 PM
  4. enum
    By JerryL in forum C++ Programming
    Replies: 5
    Last Post: 02-25-2004, 04:45 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 03:49 PM

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