Consider enum class in C++11 and above. Which of the following is a true statement about its functionality? 

  • It allows for automatic type conversion. 
  • It cannot be forward declared. 
  • It restricts the scope of the enumerator values to the enumeration. 
  • It cannot be used with switch statements.
In C++11 and later, enum class (or "strongly typed enumerations") was introduced. Unlike traditional enums, the enumerators of an enum class are not exported to the surrounding scope, thus preventing name clashes. This essentially gives them a "scoped" behavior. This feature enhances type safety and code clarity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *