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.

Computer Science & Information Technology

You might also like to view...

Level 1 cache is located farther away from the CPU than Level 3 cache

Indicate whether the statement is true or false

Computer Science & Information Technology

Excel cannot create permanent connections between an Access database and an Excel spreadsheet

Indicate whether the statement is true or false

Computer Science & Information Technology