PDA

View Full Version : darn enumerators...please help



Waldo2k2
06-07-2002, 05:36 PM
Ok, im getting very tired of my borland compiler....i followed my book to the T in this code, but it still doesn't work...with the following code:


#include <iostream>
using namespace std;

bool loggedIn=0;

int main() {
enum student (00001,00002,00003,);
enum student id;
do {
cin>>id;
switch (id) {
case 0:
loggedIn=1;
break;
case 1:
loggedIn=1;
break;
case 2:
loggedIn=1;
break;
default:
break;
};
} while (loggedIn=0);
cout<<id;
return 0;
}

i recieve the error: declaration terminated incorrectly in function main()
it is at the line that declares the enumerator (not enum student id;)...what in the heck is wrong here?
note: using curly braces {} instead of () or [] makes my compiler put out unexpected '}' errors at multiple lines...so that's not the problem...

Magos
06-07-2002, 06:03 PM
Well, it seems to me you're using enum in the wrong way.

1) You need to use { }, and not ( )

2) You're using 00001 ... 00003 as names. You cannot use numbers as names. A name must begin with a letter (with a few exceptions :))

3) You have one extra , (comma) at the end of your enum-list.

4) enum student id. You're trying to redefine student.

sean
06-08-2002, 07:11 PM
Try this sites tutorials on the subject. And I'm not surprized at your result. Borland's example code isn't the best, in fact I'm thinking of switching to DJGPP or something. I used one of their tutorials on OWL (Windows framework/library), and the code that I copy and pasted right out of the book produces 256 errors, the 256th being "processing halted due to too many errors". GOOD LUCK. YOu'll need it.