Hi everyone!
I'm having some problems with my class because they both depends on each other, to one can't be declared without the other one being declared.
class block: GtkEventBox {
public:
block(board board,guint x,guint y): image("block.png") {
this.board = board;
this.x = x;
this.y = y;
board.attach(this,x,y,x+1,y+1);
}
void move(guint x,guint y) {
board.remove(this);
this.x = x;
this.y = y;
board.attach(this,x,y,x+1,y+1);
}
private:
guint x, y;
board board;
GtkImage image;
};
class board: Gtk::Table {
public:
board(): Gtk::Table(25,20) {
blocks_c = 0;
}
void addBlock(guint x,guint y) {
blocks_a[blocks_c++] = new block(this,x,y);
}
private:
block* blocks_a[24];
int blocks_c;
};
As you can see the "block" class needs to know what a "board" is and vice versa. Thanks in advance!