I have a question concerning enumerations and floats.
I’m trying to pass an enum as a float is this possible?
Here’s an outline of the code:
enum
{
none = 0,
small,
medium,
large,
} enumSize;
class size
{
float footsize = 0.0;
}
void setSize(size &Size, float value)
{
Size.footsize = value;
}
int main()
{
size Size;
setSize(Size, enumSize);
}
However I cannot call setSize(Size, enumSize) since as far as I know enums can only be ints and cant be casted to be a float? If that’s the case is there a way to make it a float with my current setup?
If my layout is slightly confusing let me know and I’ll try to address any confusion best I can.
Of course ints can be cast to floats, but an enum is not an appropriate tool for this. Just use
const floats.By the way, your code doesn’t compile for several other reasons as well.