im trying to pass an array of objects however i m finding some problems. any help is much appriciated thanks
pieces.h
Code:
class Cpiece{
public:
Cpiece* board[8][8];// array of objects
virtual char getcolor() =0;
virtual char setcolor(char colour)=0;
virtual char getpiece()=0;
char colour;
//char getcolour();
int iskill(int newcolum,int newrow);
void getvalue(int oldrow, int oldcolumn, int newrow, int newcolumn);
virtual int validate(int oldr,int oldc,int newr,int newc, int kill)=0;
void setvalue(int oldrow,int oldcolumn,int newrow,int newcolumn);
int isvalid(int oldrow, int oldcolumn, int newrow, int newcolumn);
protected:
int oldr,oldc,newr,newc,kill;
};
piece.cpp
Code:
nt Cpiece::isvalid(int oldrow, int oldcolumn, int newrow, int newcolumn){ int check=0;
char chars;
if(board [oldcolumn][oldrow] != NULL){
switch (board[oldcolumn][oldrow]->getpiece())
{
case 'p' :
kill = iskill(newcolumn,newrow);
chars = board[oldcolumn][oldrow]->getcolor();
check=(*piece).validate(oldrow,oldcolumn,newrow,newcolumn,kill);// i need to pass the board over here
break;
}
}
if(check ==1){
getvalue(oldrow,oldcolumn,newrow,newcolumn);
}
return check;
}
cpiece.cpp
Code:
int Cponn::validate(int oldr,int oldc,int newr,int newc,int kill)// where the board must be recieved{ int check=0;
char col;
if(((oldc+1) == newc) && oldr==newr&& kill ==0){
check =1;
}
if(((oldc+1) ==newc) && ((oldr+1) == newr) && (kill ==1)){
check =1;
}
if(((oldc-1) == newc) && oldr==newr&& kill ==0){
check =1;
}
if(((oldc-1) ==newc) && ((oldr-1) == newr) && (kill ==1)){
check =1;
}
return check;
}