Imagine you are developing a system where you need to represent a fixed set of constant integral values that represent different states, and you want to restrict the variables to only allow these states. Which C++ feature would be most appropriate to use? 

  • Class 
  • Enum 
  • Union 
  • Template
Enums, short for enumerations, allow the definition of a type that can hold a set of integral constants. They provide a way to assign names to the integral constants which makes the code more readable and maintainable.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *