enum

This is a discussion on enum within the C++ Programming forums, part of the General Programming Boards category; Hey, I'm new to C++ but proficient in C...I came across enum in my book...It seems to me to fit ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    53

    enum

    Hey, I'm new to C++ but proficient in C...I came across enum in my book...It seems to me to fit the struct format which I used in C programming...Is it just used as a easily readable way to define variables? I have find you can use const to do the exact same thing? Can someone provide some clarification. Thanks

  2. #2
    Registered User
    Join Date
    Dec 2003
    Posts
    28
    I just learned the basics of that a few days ago.
    So.

    Code:
    enum Months { JAN = 1, FEB, MAR, APRIL, MAY, JUNE, JULY, AUG, SEPT, OCT, NOV, DEC, }
    Usually the values of the integer constants start at 0 unless you do other wise like my example.
    So if you do as i have did above it will increment each variable by 1 each time.

    The Months is called a user defined type.
    It's basically a set of user integer constants represented by an identifier.

    You can have the same variable names as long as you have a different user defined type as far as i know.

    I'm new so it's ll i know.
    Cya

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I'm new to C++ but proficient in C...
    C supports enum as well. It has for well over 20 years.

    >Is it just used as a easily readable way to define variables?
    You'll see enum used most often as a clever man's #define. However, they are also useful for creating integral variables with a well defined/restricted value set.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A basic question on enum
    By MasterM in forum C++ Programming
    Replies: 2
    Last Post: 06-12-2009, 10:16 PM
  2. enum switchcase and windows message q
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 11-27-2006, 01:16 PM
  3. Conflicting enum issue
    By 7force in forum C Programming
    Replies: 1
    Last Post: 07-05-2006, 04:51 AM
  4. Switch case and enum help
    By SomeCrazyGuy in forum C++ Programming
    Replies: 9
    Last Post: 04-21-2005, 09:53 PM
  5. enum
    By JerryL in forum C++ Programming
    Replies: 5
    Last Post: 02-25-2004, 05:45 PM

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