Der Aufzähltyp

Der Aufzählungstyp ist ein Grundtyp mit frei wählbarem Wertebereich, dies sei an Hand der Wochentage veranschaulicht.

//	enum
#include <iostream.h>
main()
{
//                              new enum
 enum tag
  {
    montag, dienstag, mittwoch, donnerstag, 
    freitag, samstag, sonntag
  };
 
 tag wochentag;             //  variable of enum 
 wochentag = montag;        //  data init
 
 if ( wochentag == montag )
  {
   cout << "Gute Laune, da neue Schulwoche!" << endl;
  }
}

gesamtes Programm