Can anyone look at this and help me with what is wrong. This code works, sort of- it gives me an error saying that the return choice; is not being initialized.
Based on what you said, the compiler doesn't like the fact that a enumeration object hasn't been initialised. Try initialising the enumeration objects with one of those enumerators.
Edit: Suggestion:
Maybe you can add an additional enumerator to the MediaType enumeration list, such as UNKNOWN_TYPE. It could be used for initialisation, and could also be used to indicate an unspecified choice, or "type not yet chosen".
Can anyone look at this and help me with what is wrong. This code works, sort of- it gives me an error saying that the return choice; is not being initialized.
Try initializing the variable declared on line 11 to a valid enum integer.
I tried setting choice = AUDIO_CASSETTE however when I un-commented the other cases under the Switch statement it would only create AUDIO_CASSETTES
Edit:
Maybe you can add an additional enumerator to the MediaType enumeration list, such as UNKNOWN_TYPE. It could be used for initialisation, and could also be used to indicate an unspecified choice, or "type not yet chosen".
So would UNKNOWN_TYPE take the place of default under the switch?
You're missing your break statements after each case. Also, you've got yourself a memory leak. Allow me to elaborate:
Each case allocates memory when it's executed. Since there's no break statement between each case, the compiler will move onto the next case, which will overwrite Collection's previous memory; which in turn, creates a memory leak.
brb000136 wrote:
So would UNKNOWN_TYPE take the place of default under the switch?