Subj : Re: enumerated variables - how to coerce them to anything else than an Int ? To : borland.public.cpp.borlandcpp From : R.Wieser Date : Tue Oct 11 2005 02:43 am John F(dot) schreef in berichtnieuws 434af3cd@newsgroups.borland.com... > > Hi Rudy! Hello John, > before you try any hints, read till the end and decide then what you want to > try... :-) Well, that sounds as a sane idea :-) [snip] > Then you are out of luck with that compiler... not possible at all. Drats ! That does it ! I'm going to switch to Pascal, or something else. *Surely* that language can do everything I can imagine ? :-)) [snip] > It does happen. One usually writes Well, my documentation indicated that the first value would allways be Zero, and the other elements would auto-increment (but can be overridden). Is there a (good) reason to explicitily define the value of first enumerator ? > If you like to do some "if()s" and "||"s or "&&"s you should > use 0 for _no_. Sorry, it's not my choice. Testing revealed that "default" was represented by the value 0, and No and Yes by 1 and 2 > default should be 0,1 or 2? then it can not be part of the enum. enums are > fixed. No, I ment the above assignment of values, in which "default" equals 0. [quote] > Preprocessing? That was, after just plainly putting values into the different fields, my first idea. But than I remembered C++ having enumerations, which have a very interresting feature : they can only be used with the variable they are "designed" for, something other methods (defines, constants, equates) do not have. [snip] > > The only thing I *could* do is to split a number of fields of > > the type Long into two fields of the type Int. > No good idea. No portability - little/big endian are looking > over the shoulder here... Would that not allso mean that unions cannot be used either ? Or would the (smaller) Int be aligned differently depending on the endianness ? I might be wrong, but I don't think so ... [snip] > it doesn't perform typechecking but it works... Yep, and that is what is why I thought enumerations would be apropriate ... Thanks for your suggestions, but I'm afraid those have serious drawbacks (as have my own solutions). Pre-processing seem to be more work than it's worth .... I appriciate the help though :-) Regards, Rudy Wieser .