my constructor gets ignored somehow. Here is my code:
My class:
class field
{
private:
char PlayField[5][5];
public:
char o = 'o';
field()
{
char PlayField[5][5] = { { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o }, { o, o, o, o, o } };
}
void setTile(int x_val, int y_val)
{
PlayField[x_val][y_val] = 'x';
}
char getTile(int x_val, int y_val)
{
return PlayField[x_val][y_val];
}
/*field::~field();*/
};
The constructor field() should initalize my 4 wins field with 'o's and if I want to add a Tile it will x mark where the tile is. But if I do
int main()
{
char x;
field FourWins;
//FourWins.setTile(3, 2);
x = FourWins.getTile(3, 2);
std::cout << x << std::endl;
return 0;
}
The constructor will get ignored and I get a weired sign which is most likely just currently at where I'm looking. The position finding works, becouse if I first set and x to (3,2) it will print me the x.
Any ideas?
See Question&Answers more detail:os