Importance of enum class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Importance of enum class

What is use of enum class ? I know that it makes enum element as strong cast and we cannot use the element of enum without class name i.e. enum name... but what is use case of this? any problem has been solved by this or what is the advantages for doing the same functionality?

13th Nov 2019, 12:42 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Answers
+ 2
There are two reasons I used them. 1. enum class does not propagate enumerators outside of its scope, so there is no name clashing. 2. You are able to forward its declaration. If you wanna read more I'd recommend this answer: https://stackoverflow.com/a/18338930
13th Nov 2019, 2:48 PM
Jakub Stasiak
Jakub Stasiak - avatar
+ 1
Talisman this in not the answer to the question. Btw. we got const keyword for constant values
13th Nov 2019, 4:59 PM
Jakub Stasiak
Jakub Stasiak - avatar