I'm having trouble understanding the rules on declaring members in classes.
I have initialised the char 'piece' in the classes constructor and included it as a private member in the class' header file. The program compiles and runs OK but when the function Player::print() is called there is a blank space where the 'piece' value should be.
Have I initialised the private member char 'piece' in the correct way? Looking at the tutorial on classes (http://www.cplusplus.com/doc/tutorial/classes/) I can't seem to spot the problem.
voidconst instructions()
{
cout << "\nXOXOXOX Noughts and Crosses Extreme XOXOXOX" << endl;
cout << "\nRules: Match three in a row vertically, horizontally or diagonally\n"<<endl;
}
void pieceAsk()
{
char choice;
cout << "Would you like to be Os or Xs (Enter O or X): ";
cin >> choice;
while((choice != o) && (choice != x))
{
cout << "Please enter a valid answer (X or O): ";
cin >> choice;
}
if(choice == x)
{
cout << "\nYou will play as X's\n";
onePiece = x;
compPiece = o;
}
elseif(choice == o)
{
cout << "\nYou will play as O's\n";
onePiece = o;
compPiece = x;
}
else
{
cout << "\nERROR. DEFAULT SETTING: You will play as X's\n";
onePiece = x;
compPiece = o;
}
}