Here is some code that uses an enum:
```
enum color {red, green, blue};
color paint = green;
cout << paint << endl;
```
Rewrite this using strong enums. What is the advantage of strong enumerations over the old style enumeration?
```
color paint = color::blue;
switch (paint)
{
case color::red:
cout << "red";
case color::green:
cout << "green";
case color::blue:
cout << "blue";
}
```
You may have discovered that you cannot print out an enum class with cout. This is because enum classes are strongly typed and are not a simple mapping to integers. This allows for stronger type checking which can help prevent storing invalid values in an eum class variable.
You might also like to view...
Which of the following does the C++ language not support?
a) classes b) global functions c) automatic garbage collection d) support for object oriented programming e) traditional programming techniques
Convert the example of GEOMETRY_OBJECTS given in section 11.1.5 from the functional notation to the notation given in Figure 11.2 that distinguishes between attributes and operations. Use the keyword INHERIT to show that one class inherits from another class.
What will be an ideal response?
?A host that provides storage space for saving and retrieving records is called a _____.
A. ?spool server B. ?cast server C. ?proxy server D. ?file server
The jQuery __________ method changes an element's display value to none.?
Fill in the blank(s) with the appropriate word(s).