|
From: Ioannis V. <no...@ho...> - 2002-04-17 18:14:17
|
A more ANSI C++ compliant code would be:
#include <iostream>
#include <cstdlib>
int main ()
{
using std::cout;
using std::endl;
using std::system;
enum {Dog,Cat,Horse,Pig};
int i;
for (i = Dog; i <= Pig; i++)
cout << "i = " << i << endl;
system("pause");
return 0;
}
or check the comments i have placed in your code.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
<http://www.noicys.cjb.net/>
* Alternative URL: http://run.to/noicys
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Bob
Wilson
Sent: Wednesday, April 17, 2002 3:03 PM
To: Dev-C++ User Mailing List
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 <iostream>
#include <conio_mingw.h>
Not portable.
#include <stdio.h>
Not needed.
// #include <windows.h>
Header file for system extensions. Non needed.
// #include <stdlib.h>
// #include <time.h>
Not needed.
enum {Dog,Cat,Horse,Pig};
int main (int argc, char *argv[])
{
int i;
for (i = Dog; i <= Pig; i++)
std::cout << "i = " << i << std::endl;
std::cout << "\n\nHit any key to close window . . .";
while (!kbhit());
Not needed system extension.
return 0;
}
|