Thread: darn enumerators...please help

  1. #1
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001

    darn enumerators...please help

    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:
    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...
    PHP and XML
    Let's talk about SAX

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    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.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Darn you VB!
    By FlyingIsFun1217 in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2007, 11:07 PM
  2. How to use enumerators to store input
    By Rubiks14 in forum C++ Programming
    Replies: 4
    Last Post: 10-16-2005, 09:43 PM
  3. Those darn API's
    By Zahl in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-04-2003, 10:27 AM
  4. Darn Printer
    By itld in forum Linux Programming
    Replies: 3
    Last Post: 02-27-2002, 06:50 AM
  5. Replies: 7
    Last Post: 12-29-2001, 11:25 PM