====== Der Aufzähltyp ======
Der Aufzählungstyp ist ein Grundtyp mit frei wählbarem Wertebereich, dies sei an Hand der Wochentage veranschaulicht.
// enum
#include
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|
// enum
#include
main()
{
// new enum
enum tag
{
montag, dienstag, mittwoch, donnerstag, freitag, samstag, sonntag
};
// Variable of enum type
tag wochentag;
int i,j;
bool bi;
// Data init
wochentag = montag;
if ( wochentag == montag )
{
cout << "Schlechte Laune" << endl;
}
cout << " i : ";
cin >> i;
bi = i < 8;
for (j=1; j<=5; j++)
{
if (bi)
{
cout << "use stored test result = " << bi << endl;
}
}
}
++++