Thread: Parse Error

  1. #16
    Registered User
    Join Date
    Jun 2002
    Posts
    39
    I tried moving "menu2()" out of "cityBertopia". But it just causes more errors. If it matters, I moved "int choice = menu2();" out. I don't think I can move just "menu2()".
    Compiler: Dev-C++ 4.9.8.0

    -Bert

  2. #17
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    roa_v3-0.cpp
    Code:
    int menu2()
    {
    int choice2;
    cout << "The city you are currently in is Bertopia. \n\n";
    
    cout << "**** Menu ****\n\n";
    cout << "(1) Battle \n";
    cout << "(2) Shop \n";
    cout << "(3) Train \n";
    cout << "(4) Check Status \n";
    cout << "(5) Inventory \n";
    cout << "------ \n";
    cout << "(6) Go east or Mordavia \n";
    cout << "(7) Go south to Dinxopolis \n";
    cout << "(8) Go south east to Swamp City. \n";
    cout << "------ \n";
    cout << "(9) Save Game \n";
    cout << "(10) Load Saved Game \n";
    cout << "(11) Quit \n";
    cout << ": ";
    cin >> choice2;
    return choice2;
    }
    
    void cityBertopia()
    {
    #include "cityBertopia.cpp"
    }
    citybertopia.cpp
    Code:
        bool exit = false;
        do
        {
            int choice2 = menu2();
            switch(choice2)
            {
            case (1):
                    battleKnight();
                    break;
            case (2):
                    shop();
                    break;
            case (3):
                    train();
                    break;
            case (4):
                    check_status();
                    break;
            case (5):
                    inventory();
                    break;
            case (6):
                    cityBertopia();
                    break;
            case (7):
                    cityDinxopolis();
                    break;
            case (8):
                    cityMordavia();
                    break;
            case (9):
                    saveFile();
                    break;
            case (10):
                    loadFile();
                    break;
            case (11):
                    exit = true;
                    break;
    
            default:
                    cout << "Invaild Command. Please select again.\n\n";
                    break;
            }
         }while(!exit);
    "Logic is the art of going wrong with confidence."
    Morris Kline

  3. #18
    Registered User
    Join Date
    Jun 2002
    Posts
    39
    That didn't work. It displayed the same 4 errors.
    Compiler: Dev-C++ 4.9.8.0

    -Bert

  4. #19
    Registered User fletch's Avatar
    Join Date
    Jul 2002
    Posts
    176
    Bert,

    This thread has deteriorated to the point of "Help me. Your last suggestion didn't work, give me another idea."

    This is starting to move beyond casual assistance. You need to solve this problem. If you desire to continue programming, you have to learn to understand compiler errors and look through your own code to find the problem. Myself and others are more than willing to assist you, but there has to be effort on your part. There are a lot of talented people here; some of these people program professionally, others are enthusiasts - all generously offer their help and knowledge. Their time is precious. Do not waste their time by asking for help with a problem you have not been willing to spend your own time on.

    That said...

    Parse errors are typically grammatical errors of some sort; missing punctuation marks such as { } ; ( ) Look through your code and make sure that all of your syntax is correct. Try looking at the code preceeding 'cityBertopia.cpp'

    Regardless of its legality, defining functions within other functions is definitely poor practice. Menu2() needs to be its own function, outside of cityBertopia().

    If you encounter further problems or have other questions, do not hesitate to ask, but only after you've attempted a solution yourself.

    I'm curious as to what you find the problem is and I'd be interested in seeing your finished program. Please let me know.

    fletch
    "Logic is the art of going wrong with confidence."
    Morris Kline

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM