Does anybody know i you can and if so how i do it. I have a enum of colors. I'm using this when calling certain functions of a class. Within then they use switch/case using the various enum's to do what ever they do.
This all works fine the thing is i want to also be able to call those functions but use a int in place of the enum. Basically so i can map a analog input to the enum range and also select it that way.
Sorry that was a really bad post. I know, was a bit to tired to copy the code.
Yes i control the class, and i'm sending the enum to it when i call it.
Yes i know i could change the class to take both but i was thinking as an enum's a sort of int anyway i could just cast it. ( if that makes sense) .So i dont have to re wright a load of functions
the enum
#include "WProgram.h"
enum Color {
RED,
GREEN,
BLUE}
Using it
Color Currant_color;
Currant_color=RED;
// prototype
void ColorSet(Color this_Color); // havent included the function it's self to keep it simple
//calling the function
ColorSet(Currant_color);
// wanted to do something like this to including the mapping
Currant_color=(int)1; // for green
ColorSet(Currant_color);
Hope thats clear enough had to just wright that up, so i've not compiled this it's just to give an idea it basically like that.
I'm thinking ive got it the wrong way round from what you said. If i send a int to the function i can use the enum in it's place when calling the function?. But not the other way round.
Then, you can call instance.SetColor(White); or instance.SetColor(4);.
Without the enum overloaded version you put. This seems to work if it's sent a enum or a int. Is this because a enum is like a definition of an integer? Is this correct?