I'm writing Chess in what little free time I have these days, and I'm currently working on getting the pieces to calculate their possible moves. My specific problem is with pawns, which can only move in a single direction, determined by where they started (i.e. by color). Anyways, I'm trying to create a forward pointer that will get the square "in front" of where the pawn is now.
I have the line in pawn.cpp:
Square (*fwd)() = (getColor() == White) ? &Square::up : &Square::down;
where Square::up() and Square::down() are public functions declared in square.h as
public: /* ... */
Square* up();
Square* down(); The error I get is:
Quote:
pawn.cpp:16: error: cannot convert `Square*(Square: )()' to `Square (*)()' in initialization
|
Is there a good way to get this to work? For that matter, what exactly does this error message mean? I'm thinking that it's complaining about making a pointer to a function specifically inside the Square class. Should I perhaps rethink how I'm doing this?
BTW, I'm compiling using g++ and running Linux, not that it should matter for this...