Virtual Functions

Hey,
I am writing a chess game, in which each type of piece is a dervied class of the base class Piece. Piece class has a virtual function
 
virtual bool CheckValidMove(int CurrRow, int CurrCol, int DestRow, int DestCol, Piece* Square[][8])


The behaviour of this function varies across the different derived classes. However, when I build it, I get the linker error:


1>Chess.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall Piece::CheckValidMove(int,int,int,int,class Piece * (* const)[8])" (?CheckValidMove@Piece@@UAE_NHHHHQAY07PAV1@@Z)



Can someone explain what exactly the problem is and how I can correct it ?
It means that either you forgot to define this virtual function of your Piece class or you did not include a module that contains the definition in your project.
I definitely defined the virtual function in the Piece class .... but I didn't understand what you exactly meant in the second part
In class Piece, did you declare your virtual function as
virtual bool CheckValidMove(int CurrRow, int CurrCol, int DestRow, int DestCol, Piece* Square[][8]);

or

virtual bool CheckValidMove(int CurrRow, int CurrCol, int DestRow, int DestCol, Piece* Square[][8]) = 0;

If the former, you still need to implement the method Piece::CheckValidMove(...)

You should probably change it to the latter, forcing all sub classes to implement this method.

Last edited on
Topic archived. No new replies allowed.