Thread: Enumerators seem like an unneeded stock c++ convention

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    19

    Enumerators seem like an unneeded stock c++ convention

    I'm just learning, but at this point it seems to me that there isn't a difference between an enumerator and creating you own data type of the "typedef const unsigned int" format. Am I not seeing the full picture?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Delicieuxz
    I'm just learning, but at this point it seems to me that there isn't a difference between an enumerator and creating you own data type of the "typedef const unsigned int" format. Am I not seeing the full picture?
    A distinctive difference is that an enumeration declaration, um, enumerates the various permitted values, even though this is not enforced by the compiler, whereas a simple typedef does not.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    "enumerators", as in things that enumerate?!
    Perhaps you mean "enumerations"?

    I'm sure we don't really need to go over this again. You must be perfectly capable of searching for the dozen or so existing thread on this site asking the same question, or on the rest of the interwebs for that matter.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Aug 2012
    Posts
    19
    Quote Originally Posted by laserlight View Post
    A distinctive difference is that an enumeration declaration, um, enumerates the various permitted values, even though this is not enforced by the compiler, whereas a simple typedef does not.
    Ah, right. I didn't grasp that part while studying earlier. It clicked afterwards. Thanks.

    Quote Originally Posted by iMalc View Post
    "enumerators", as in things that enumerate?!
    Perhaps you mean "enumerations"?

    I'm sure we don't really need to go over this again. You must be perfectly capable of searching for the dozen or so existing thread on this site asking the same question, or on the rest of the interwebs for that matter.
    When you're genuinely learning, you often either feel that your question is idiosyncratic, or are unsure of how it would be phrased in a manner which would cover what you're confused about - and your corrective distinction between enumerators and enumerations helps drive that point home. Although, my use of enumerator instead of enumeration was correct. I wasn't asking regarding the concept of enumeration (considering I wasn't then aware of the actual enumeration that was taking place), but the point of the existence of the "enum" keyword, which does enumeration but which is an enumerator, in lieu of making ones own identical new date type with typedef. I see the difference now.
    Last edited by Delicieuxz; 08-21-2012 at 06:14 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enumerators vs Magic no.s
    By manasij7479 in forum C++ Programming
    Replies: 11
    Last Post: 05-24-2011, 01:08 AM
  2. Enumerators as strings
    By Mario F. in forum C++ Programming
    Replies: 14
    Last Post: 07-19-2006, 01:26 PM
  3. unneeded includes
    By Laserve in forum C Programming
    Replies: 3
    Last Post: 12-13-2005, 07:24 PM
  4. Replies: 2
    Last Post: 01-04-2003, 01:16 AM
  5. darn enumerators...please help
    By Waldo2k2 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 06-08-2002, 07:11 PM