Is is possible to write a anonymous enum class and then comparing what it contains? Eg.
enum class { APPLE, BANANA } fruitType;
// ...
if (fruitType == fruitType::APPLE)
// ...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No,
fruitTypeis a variable (despite Type in the name). You cannot use a variable name to access things about its type.The idea with
enum classis that the values are not visible outside the definition unless you prefix them with the type name. If the type doesn’t have a name, this will be difficult!