| HellfireXP (71) | |||
I'm trying to figure out how to loop through enums. The code below doesn't work, but is an example of the concept I'm trying to work through:
The problem I have is that the ++d is giving me the compiler error; I know it has to do with not being able to convert int types to enums, even though it works the other way around.My question is how do I get around this? Can I create an operator overload like I do in classes to allow addition for my loop to work? Or is there an easy way to loop through enums that I'm not aware of? | |||
|
|
|||
| LowestOne (896) | |||
//Loop through each direction and do something But what are you trying to do? The use for an enumerator is to define a type that you would otherwise have to keep a "magic number" for. You also receive type safety:
Not exactly sure what use the actual integral value is (but we can define it, so there must be one). | |||
|
Last edited on
|
|||
| HellfireXP (71) | |||||
Ok.. I figured it out..
LowestOne... thanks for the attempt.. what i'm doing is writing a "Lights Out" puzzle game. I'm testing out a game engine I'm writing. I got it working, but you can see at the bottom of this code where I'm using the enum loop...
| |||||
|
Last edited on
|
|||||
| LowestOne (896) | |
|
But why are you doing that? I said this before HellfireXP's edit | |
|
Last edited on
|
|
| HellfireXP (71) | |
| For fun. | |
|
|
|