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;
}