Thread: Tricking enums

  1. #1
    myNegReal
    Join Date
    Jun 2005
    Posts
    100

    Tricking enums

    I'm sure there's got to be a way to do this. Is there some way to trick the compiler into allowing a redefinition of an enum. For example say you have:
    Code:
    enum type {};
    and then you want to define the values at a later time. How would you go about doing this?
    Using Dev-C++ on Windows

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Why?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Is there some way to trick the compiler into allowing a redefinition of an enum
    No there isn't.

    You can do stuff like that with the pre-processor (#define and #undef), but not with the language proper.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    You probably want to use variables instead of constants/enum values/#defines if the values are going to change.
    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. Serialization of Enums
    By khdani in forum C# Programming
    Replies: 1
    Last Post: 04-27-2009, 10:57 AM
  2. Replies: 23
    Last Post: 07-09-2007, 04:49 AM
  3. Enums and Templates
    By einarp in forum C++ Programming
    Replies: 5
    Last Post: 07-19-2006, 05:07 AM
  4. printing enums
    By xddxogm3 in forum C++ Programming
    Replies: 19
    Last Post: 08-09-2005, 12:08 PM
  5. enums!
    By newjamie in forum C Programming
    Replies: 1
    Last Post: 03-13-2002, 12:25 PM