Enumerated Data Types


  • This is used when you know in advance the finite number of values a variable can take in a program. E.g. The days of the week can only take values from Sunday to Saturday.
  • An ‘enum’ specifier defines the set of all names that will be permissible values of the type. These values are called ‘members’ of the data variable. ‘Enumerated’ means that all values are listed.
  • These data types are treated internally as integers. The first member gets value 0, the second 1, and so on.
  • Changes can be done by assigning it in the declaration. The values can be set by initializing the first value.
  • In following example, Sunday is initialized the value 1. Thus Monday gets the value 2 and so on. If the difference between the first and second value is more than 1, the values must be specified explicitly while declaring the data type.
  • E.g. Sun = 10, Mon = 20, and so on. Click here For Enumarated data type Examples


Input and output operations << Previous

Next >> C++ operator

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus




Footer1