# Simple C++ question

• 09-03-2006
surfmore
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
• 09-03-2006
ZuK
You can't. Enumerations are integral types.
Kurt
• 09-03-2006
surfmore
I need to assign those numbers to enumerations, so their is no way to do it?
• 09-03-2006
Daved
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.
• 09-03-2006
surfmore
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.
• 09-03-2006
Daved
>> 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.
• 09-03-2006
Cat
You could use the enumerations (which are integers) as indexes into an array of doubles. That's about the closest you can get.
• 09-03-2006
surfmore
How would you do that?
• 09-03-2006
mrafcho001
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
• 09-03-2006
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