|
From: Jason H. <jas...@bt...> - 2002-04-17 14:27:55
|
The default is 0, and then each consequtive one is +1 the previous one. =
You can change the value of an enum by initialising it to something =
else, i.e.
enum farmyard {cow, sheep, pig, chicken, fruitbat =3D 1000, elephant, =
pigmi}
so cow =3D 0, sheep =3D 2, etc.. and then fruitbat =3D 1000, elephant =
=3D 1001, and so on.
Jason.
----- Original Message -----=20
From: Bob Wilson=20
To: Dev-C++ User Mailing List=20
Sent: Wednesday, April 17, 2002 1:02 PM
Subject: Re: [Dev-C++] enum
Daniel;
when you enumerate variables, is the first one (by default) 0 or 1 ?
Run this little program and you will get your answer.
#include <iostream.h>
#include <conio_mingw.h>
#include <stdio.h>
// #include <windows.h>
// #include <stdlib.h>
// #include <time.h>
enum {Dog,Cat,Horse,Pig};
int main (int argc, char *argv[])
{
int i;
for (i =3D Dog; i <=3D Pig; i++)
std::cout << "i =3D " << i << std::endl;
std::cout << "\n\nHit any key to close window . . .";
while (!kbhit());
return 0;
}
|