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
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
You can't. Enumerations are integral types.
Kurt
I need to assign those numbers to enumerations, so their is no way to do it?
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.
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.
>> 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.
You could use the enumerations (which are integers) as indexes into an array of doubles. That's about the closest you can get.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
How would you do that?
is what he meansCode:enum something {somethign1, something2, something3}; double array[3] = {2.382, 23.28, 21.2324}; array[something1] //when you want to access the number
Declare the enum and an array of double (or float) values....
then use the enum values to reference a position in the arrayCode:enum { one, two, three, } float m_array[20];
remember that the array is zero basedCode:m_array[one]=0.2435; m_array[two]=1.5464; m_array[2]=0.65464;