# Simple C++ question

This is a discussion on Simple C++ question within the C++ Programming forums, part of the General Programming Boards category; I'm new to programming in C++ so I appreciate any help... How can I assign a value of 2.4567 to ...

1. ## Simple C++ question

I'm new to programming in C++ so I appreciate any help... How can I assign a value of 2.4567 to a enumeration type? ---tia

2. You can't. Enumerations are integral types.
Kurt

3. I need to assign those numbers to enumerations, so their is no way to do it?

4. You can't assign that value to an enumeration type. Use a const double instead, or provide more information about why you think you need to do that.

5. I have to use an enumerated type for the programming assignmnet I'm doing. The way it goes is that I have to incorporate a list of items with associated numbers to go along with it. The numbers are 0.56789 for example.

6. >> I have to use an enumerated type for the programming assignmnet I'm doing.
You have to use an enumerated type because the assignment said to use an enumerated type, or because you think that is the only way to solve the problem?

>> The way it goes is that I have to incorporate a list of items with associated numbers to go along with it.
I wouldn't use an enumerated type for that.

7. You could use the enumerations (which are integers) as indexes into an array of doubles. That's about the closest you can get.

8. How would you do that?

9. Code:
```enum something {somethign1, something2, something3};

double array[3] = {2.382, 23.28, 21.2324};

array[something1] //when you want to access the number```
is what he means

10. Declare the enum and an array of double (or float) values....

Code:
```enum {
one,
two,
three,
}

float m_array[20];```
then use the enum values to reference a position in the array

Code:
```m_array[one]=0.2435;
m_array[two]=1.5464;
m_array[2]=0.65464;```
remember that the array is zero based