Subj : Re: enumerated variables - how to coerce them to anything else than an Int ? To : borland.public.cpp.borlandcpp From : John F\(dot\) Date : Mon Oct 10 2005 11:08 pm "Ed Mulroy" schrieb im Newsbeitrag news:434ac54c$1@newsgroups.borland.com... > In Win32 an int IS a long. They are both 4 byte signed values. > > The C++ Language spec states that the conversion between an int and an > enum is intrinsic so, be it an int or a long, assignment of anything, even > if it is not one of the enum values is possible. > > The way I would try to limit what can be put into it is to define a class > and overload the basic operations, checking for valid enum values and > doing something for invalid ones. Then I would use that instead of the > enum. > > You appear to be using an existing class. You might design a class which > inherits from that existing one and which makes your LongEnum interface > visible instead of the enum one. You will then be able to do whatever you > want with it. > > . Ed Hi Ed, Thats the correct way... the question is if he still needs arbitrary longs to be stored in those members. If not, he can do anything... What I suspect is that Rudy wants sth like long X will then be: enum MyLong X; .... X=123456789; //should be able to store it. X=default; so he would need X to take 4 bytes. It can be done the dirty way (that wouldn't waste many kBs of Memory...). (at least with OW1.3 [gives a warning on that...], I will check with BC as soon as possible maybe at weekend) regards John .