Jump to content
  • Advertisement
Sign in to follow this  
Si0n

Can enumerations hold Char?

This topic is 4884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I 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?

Share this post


Link to post
Share on other sites
Advertisement
It is possible, it might even be useful in some cases. I'd say in general, it's poor design, but there could exist places where it's the simplest thing that might work.

Share this post


Link to post
Share on other sites
They 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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Si0n
I 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]

Share this post


Link to post
Share on other sites
Quote:
Original post by HarryW
They 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.


Nothing really, jsut out of cursiosity. ;)

And I'm using C/C++

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!