Thread: declaring enums

  1. #1
    Registered User
    Join Date
    Apr 2019

    declaring enums

    can i have two enums with the same keywords but different values and titles ie
    enum value { TWO = 2, THREE, FOUR........ ACE};
    enum score_value {TWO = 2 THREE = 3, FOUR = 5.... ACE = 41};

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Have you tried writing a test program?
    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
    Registered User
    Join Date
    Apr 2019
    im banging my head against a wall trying to come up with an algorithm to score each possible poker hand uniquely The test i tried said i was redeclaring two etc etc i wondered if there was a way to do it.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    In C, enum values are global. They're like fancy #define constants. If you don't want their names to conflict, you need to either give them different ones or add some sort of prefix that distinguishes them.
    Devoted my life to programming...

  5. #5
    TEIAM - problem solved
    Join Date
    Apr 2012
    Melbourne Australia
    Could score_value be implemented as a function where you enter enum value and get a integer returned?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-04-2014, 11:40 AM
  2. Could someone please clarify enums for me
    By samwillc in forum C++ Programming
    Replies: 24
    Last Post: 04-23-2013, 05:54 PM
  3. scoped enums only available with -std=c++0x or std=gnu++0x
    By Brian_of_Bozeat in forum C++ Programming
    Replies: 5
    Last Post: 12-01-2011, 09:11 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

Tags for this Thread