The code is not yet completed, so many functions are not being used!
But now to the problem:
As you can see in the void Peg_t::UserMove() function, I am making the program check if the specified move is on a blank position or not.
Now when I run the program this is what happens:
1 2 3
1 | |
-|-|-
2 | |
-|-|-
3 | |
Please enter the position of the Place you want to move: 11
1 2 3
1 | |
-|-|-
2 | |
-|-|-
3 | |
You made an illegal move! Turn Skipped
--------------------------------------------------------------------------------
This happens for all the nine moves, on all the turns. Any help??
At that point, the contents of board[0] (which is the board object inside the peg_t object, which is not the board object you previously set to contain spaces) is the number zero (or possibly some random number, depending on your system), which unfortunately can print out as a space. The actual space character you are comparing it to, ' ', has the numerical value 32.
Well yes, I did wan't only one Board array. I guess I misunderstood the concept of Inheritance!
So if I want to access the board in the Board_t class, can I do it by Board_t::board[0]?
The name of your actual created object is Board. Board_t is the name of the kind of thing it is, but there's no actual created object here named Board_t.