Thread: enumeration design question

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What is the benefit over the namespace suggestion above? You are just making things more complicated for absolutely no benefit [unless you can give a benefit that you think is worth the extra complexity]. Why is putting an enum inside a class more beneficial?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #17
    Registered User
    Join Date
    May 2006
    Posts
    630
    Quote Originally Posted by matsp View Post
    What is the benefit over the namespace suggestion above? You are just making things more complicated for absolutely no benefit [unless you can give a benefit that you think is worth the extra complexity]. Why is putting an enum inside a class more beneficial?

    --
    Mats
    Its because the communication betwen the server and client uses serialization (message classes) and I would like one particular class to have same enums and they could be accessed (written) this way: the_class::the_enum; (without writing them two times - once in a namespace and once in that class).

    It makes more sense if you write some_message test; test.set_state(some_message::some_state) instead of test.set_state(client::some_state);
    Last edited by l2u; 04-14-2008 at 09:30 AM.

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    In that case, I would put the enum INSIDE the class, and also produce the serialization code in that class.

    I don't know for sure if you can achieve this with templates...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Game design question
    By h3ro in forum Game Programming
    Replies: 6
    Last Post: 02-28-2008, 08:20 AM
  2. Question about engine design.
    By Shamino in forum Game Programming
    Replies: 9
    Last Post: 01-29-2008, 10:53 AM
  3. question about class design and overloading
    By l2u in forum C++ Programming
    Replies: 7
    Last Post: 12-13-2007, 02:02 PM
  4. database app design question
    By MPSoutine in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2003, 10:13 PM
  5. design question: opinion
    By ggs in forum C Programming
    Replies: 2
    Last Post: 01-29-2003, 11:59 AM