Question related to enum

This is a discussion on Question related to enum within the C Programming forums, part of the General Programming Boards category; Hi to all! I'm confused as far as "enum" is concerned! Code: typedef struct TableRecord { union { variable* var; ...

  1. #1
    g_p
    g_p is offline
    Registered User
    Join Date
    Dec 2006
    Posts
    85

    Question related to enum

    Hi to all!

    I'm confused as far as "enum" is concerned!

    Code:
    typedef struct TableRecord {
    
    union {
    variable* var;
    function* fun;
    } t;
    enum symbolType;  /* What does enum do here with the variable symbolType??? */
    
    } TableRecord;
    Thanks in advance

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    It doesn't do anything, or perhaps it's a forward declaration for the enum symbolType.

    Perhaps it would help if you knew what an enum was: http://www.cprogramming.com/tutorial/enum.html

    enums have much the same syntax as structs and unions. An enum has the basic form
    Code:
    enum tag {
        data
    } variable;
    If the tag is present, it declares the enum as a type, but it doesn't actually create a variable. If the variable nam is present, an instance of the enu is declared, but you can't reference the enum type anywhere else because it doesn't have a tag. Both the tag and the variable can be present. (You can get anonymous enums, too, with neither a tag nor a variable name.) And you can have multiple variable names, just like structures.

    The data in the enum is a list of names, with this basic form:
    Code:
    enum { value1, value2, valueN } ;
    The first is assigned zero, unless you change it:
    Code:
    enum {
        two = 2,
        three
    };
    Succeeding values are one greater than the previous value, unless they are also assigned a value.
    Code:
    enum {
        negative = -1,
        positive = 1
    };
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question related to keypad
    By lovemagix in forum C++ Programming
    Replies: 22
    Last Post: 01-05-2006, 02:25 AM
  2. A Little Performance Related SDL Question...
    By Comrade_Yeti in forum Game Programming
    Replies: 14
    Last Post: 12-09-2005, 07:46 PM
  3. another exercise question
    By luigi40 in forum C# Programming
    Replies: 3
    Last Post: 11-28-2005, 03:52 PM
  4. Enum question
    By Bill 101 in forum C Programming
    Replies: 4
    Last Post: 10-31-2002, 12:33 AM
  5. enum question
    By incognito in forum C++ Programming
    Replies: 1
    Last Post: 12-30-2001, 12:04 AM

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