Share this post

Link to post

Share on other sites

Original post by Si0nI figured they could, since char is an integral value and it would be able to cast it right? But is it worth it, good style, etc?

You didn't mention which language you're using, but if the language you're talking about supports changing the underlying type of an enumeration, make sure it allows a change to char before you start planning. For instance, while C# allows you to change the underlying type of an enumeration, it doesn't let you switch to char (for various reasons).

In general, though, you should feel free to do whatever you like with enumerations as long as it's good programming practice. Writing out an enumeration like

enum Numbers{ Zero = '0', One = '1', // ...}

is a bit silly, for instance.

[Edited by - kSquared on January 8, 2005 10:57:50 AM]

0

Share this post

Link to post

Share on other sites

Original post by HarryWThey can. If it solves your problem in a simple way, and is clear to someone reading the code, then I'd say it's good design. I'm intrigued to know what you're thinking of using it for.