⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽

Enumerations

Computer Programming C++ / Defining New Data-Types

An enumeration (enum) is a finite collection of named values. Usually enums are a better way to keep track of settings or states than using ints or strings, because most modern ide's will provide intellisense for you. This video will explain.

When enums get compiled they are actually replaced with ints (by default). Computers are good at working with numbers, so it has no problem rembering that an instructor is a '0,' and a student is a '1,' etc. Alternatively, as humans, we're generally better at remembering the names of things. Enums give us the best of both worlds.

Review Questions

The following are examples of questions similar to what you can expect to see on the next exam.

Hover over a question to show the answer.
  1. What is an enumeration? A set of named values.
  2. What is the default backing type for an enum? int

Above and Beyond

The content past here is related, but beyond the scope of the class. In other words, you will not be tested on this!

More on Backing Values

Below is an example of how backing values can be usefull, especially when combined with bitwise operators.

⧼⧼  Previous Page
⧼  Table of Contents  ⧽
Next Page  ⧽⧽
© Ryan Appel