Is it possible to use switch with enum? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is it possible to use switch with enum?

I'd like to have user input select the enum value and then evaluate the integer portion of it with switch but am unsure of how.

7th Jul 2019, 2:54 AM
Isaiah Condreay
3 Answers
+ 1
Directly use user input names of enum u cant its like const variable names. U should do some conversion from string or use integer values. https://code.sololearn.com/cqd9nHVizok7/?ref=app
7th Jul 2019, 11:42 AM
Chicherin Alexey
Chicherin Alexey - avatar
0
of course if your question about Cpp? 😉
7th Jul 2019, 11:43 AM
Chicherin Alexey
Chicherin Alexey - avatar
0
Ya, I'm an intermediate coder with cpp, so that's what I'm familiar with, but I've decided to learn cs
7th Jul 2019, 3:30 PM
Isaiah Condreay