By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,506 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

TicTacToe Problems

P: 5
Old title: Homework Due 2-20-07

can"t understand why this will not compile. I've been working on tis all week end.
Need Help desperately






Expand|Select|Wrap|Line Numbers
  1. class TicTacToe
  2. {
  3.     public:
  4.             static void newGame();
  5.  
  6.     private:
  7.  
  8.             static char board[3][3]; // priviate menbers
  9.             static char turn;
  10.             static char turn2;
  11.             static int turnRow;
  12.             static int turnCol;
  13.             static int entryCount;
  14.             static bool entryError;
  15.  
  16.  
  17. };
  18.  
  19.     int r = 0;
  20.     int c = 0;
  21.     int entryCount = 0;
  22.     char board;
  23.     void newGame()
  24.     {
  25.         system("cls");
  26.         // set turn back to 'O'
  27.         entryCount  = 0;
  28.         for(r = 0; r < 3; r++)
  29.         {
  30.             for( c = 0;c < 3; c++)
  31.             board[r][c] = ' ';
  32.         }
  33.     }
Feb 19 '07 #1
Share this Question
Share on Google+
7 Replies


bartonc
Expert 5K+
P: 6,596
It's probably best to post the error code/message.
Isn't main() supposed to be declared void?
Feb 20 '07 #2

P: 5
the error message I'm getting is in my New Game function. It telling me that row' and column are undeclared identifiers.

The main function is the only thing about the program the teacher told use not to change, but to create the rest of the program around his main.

Warren Hoskins
Feb 20 '07 #3

Ganon11
Expert 2.5K+
P: 3,652
I see a few problems:

1) You probably shouldn't be declaring r and c outside of this function, as I';m not sure what use they'll be in the rest of your code.

2) You are also trying to declare board and entryCount at this point, but since they are static variables, you should be using TicTacToe:: somehow in the initialization (Not 100% on the syntax, so you'll have to look it up).

3) The function has a header of void newGame(), but it should be void TicTacToe::newGame().
Feb 20 '07 #4

AdrianH
Expert 100+
P: 1,251
If you still have problems, copy and paste the exact first two error message(s) and state what line that translates to in the function. Point at it/them with a comment(s).

We will see if we can further help you,


Adrian
Feb 20 '07 #5

AdrianH
Expert 100+
P: 1,251
It's probably best to post the error code/message.
Isn't main() supposed to be declared void?
Main should always be declared int as per ANSI-C standard. Some compilers may accept it, but it is not necessarly portable.


Adrian
Feb 20 '07 #6

P: 1
You should at least offer some money if you want people to do your homework for you. :)
Feb 20 '07 #7

AdrianH
Expert 100+
P: 1,251
You should at least offer some money if you want people to do your homework for you. :)
Hey watchit wisenhower, your gonna be next. ;)


Adrian
Feb 21 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.