"Missing '}' before input" error

This is a discussion on "Missing '}' before input" error within the C++ Programming forums, part of the General Programming Boards category; I have a feeling this error has little to do with my code concept, and has more to do with ...

  1. #1
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    907

    "Missing '}' before input" error

    I have a feeling this error has little to do with my code concept, and has more to do with a syntax error. Where'd I miss a '}'? What is this 'input'? Still, in its simplicity, it bothers me:
    Code:
    17 C:\Dev-Cpp\Project\tictactoe\main.cpp expected `}' at end of input
    69 C:\Dev-Cpp\Project\tictactoe\board.cpp expected `}' at end of input
    Affected lines are bolded red.
    main.cpp
    Code:
    #include <cstdlib>
    #include <iostream>
    #include "cell.h"
    #include "coordinates.h"
    #include "board.h"
    using namespace std;
    using namespace cellspace;
    
    int main(int argc, char *argv[])
    {
        boardspace::board b1,b2;
        b1 = b2; 
        b2 = b1;
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    and board.cpp
    Code:
    #include "board.h"
    using namespace cellspace;
    using namespace boardspace;
    
    board::board(char P1_in, char P2_in)
    {
     P1_symbol = P1_in;
     P2_symbol = P2_in; 
     for(int a = 0; a < 3; a++)
     {
             for(int b = 0; b < 3; b++) cells[a][b/*to prevent tag*/].coord::assign(b, -(a) + 2);
     }
    }
    
    board::board()
    {
     P1_symbol = 'X';
     P2_symbol = 'O'; 
     for(int a = 0; a < 3; a++)
     {
             for(int b = 0; b < 3; b++) { cells[a][b/*to prevent tag*/].coord::assign(b, -(a) + 2); }
     }
    }
    
    board::~board() { delete [] cells; } 
    
    inline cell board::get_cell(int x_in, int y_in)
    {
     if(x_in > 2 || x_in < 0 || y_in > 2 || y_in < 0) { throw exception::OUT_OF_BOUNDS(); }
     return cells[-(y_in) + 2][x_in];
    } 
    
    inline cell * board::access(int x_in, int y_in)//returns a reference pointing to that part of the board array.
    {
     return &cells[-(y_in) + 2][x_in];
    }
    
    board board::operator = (board other)
    {
          P1_symbol = other.get_P1();
          P2_symbol = other.get_P2();
          for(int a = 0; a < 3; a++)
          {
                  for(int b = 0; b < 3; b++)
                  {
                          *access(a,b) = other.get_cell(a,b);
                  }
          }
          return *this;
    }
    
    RETURN_NOTICE board::move(short int which_player, int x_in, int y_in, board* out = NULL)
    {
          board * temp;
          if(x_in > 2 || y_in > 2 || x_in < 0 || y_in < 0 || which_player < 1 || which_player > 2) return OUT_OF_BOUNDS;
          else if(get_cell(x_in,y_in).is_occupied()) return NO_VACANCY;
          else if(out == NULL)
          {
           access(x_in, y_in)->assign((which_player == 1) ? P1_symbol : P2_symbol);
          }
          else
          {
           temp = new board;
           *temp = *this;
           temp->move(which_player, x_in, y_in, NULL);
           *out = *temp;
          }
          return SUCCESS;
    } 
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Check your headers, starting with board.h.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    An include statement inserts the contents of the header file at the spot of the include, so even though the error messages direct you to main.cpp and board.cpp the error coud be in the included header files. Since board.h is incuded in both files, there's a good chance it's in there.

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    907
    Well there we have it. Thank you.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 02:17 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21