A record's status should say what it means. Numbers such as zero and one can become confusing when a program has several kinds of states. An enumeration defines a type whose named values represent a set of choices.
#include <iostream>
enum class DoorState { closed, open };
int main() {
DoorState door = DoorState::open;
if (door == DoorState::open) {
std::cout << "Enter" << '\n';
}
}
enum class DoorState declares a scoped enumeration. The words in braces name its values. DoorState::open selects the open value belonging to this type; the :: keeps that name associated with its enumeration. The semicolon ends the definition.
Although the spelling contains class, this is not a lesson about building classes with constructors or methods. Here those two words together define a scoped enumeration. A DoorState variable should hold the relevant named states, not an unrelated integer code. Unlike an ordinary integer, a scoped enum is not implicitly converted to a number for output.
Use comparisons or a switch to turn a state into a display label. An enumeration stores the program's choice; a string is how you explain that choice to a person. Keeping the two roles distinct means the rest of the program need not compare user-facing messages.
In the starter, StockState distinguishes ready stock from stock on order. The supplied switch already chooses a branch; replace the temporary text in each branch's return. A return leaves the entire function, so these cases do not need break. Leave the final "Unknown" fallback in place. The two calls in main exercise the named states separately.
"In stock" for StockState::ready. Expect Ready label: In stock."On order" for StockState::ordered. Expect Order label: On order.Edit main.cpp, then select Run to inspect the Console. Select Submit to check your completed tasks.