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.
Loading...
Related Quiz
- What does the -> operator do in the context of pointers in C++?
- Which arithmetic operator is used to perform division in C++?
- You are tasked with optimizing a piece of code containing nested loops...
- How does a range-based for loop work in C++11 and above?
- A class that contains at least one pure virtual function is called a(n) _______.