![]() |
|
#1
|
|||
|
|||
expected primary-expression before '{' tokenHi I am having trouble with an assignment for my advanced C++ class. I am using dev-C++ to compile it and it is giving me a bunch of errors along the lines of "expected primary-expression before '{' token "
I have been searching for a week now. I even re-wrote the entire project trying to fix this. Here is the code, it is a bit sloppy, partially because the instructions called for solving the problem with a 2d Array. This is not how I would have originally solved it so I had to do it in a different way: Main file: CPP / C++ / C Code:
Class Header: CPP / C++ / C Code:
Class .cpp file CPP / C++ / C Code:
It's probably something simple that I'm missing but it is driving me crazy that I can't find it. If somebody knows what is causing this I would greatly appreciate it if you would let me know. Thanks for the help. EDIT: The compiler is only showing errors in the Class .cpp file. EDIT2: I have corrected a couple of syntax errors and updated the Class .cpp |
|||
|
#2
|
||||
|
||||
Re: expected primary-expression before '{' tokenSemi-colons are not used after function definitions.
For example: (see the comment) CPP / C++ / C Code:
Also, you have a do-while loop that DOES need a semi-colon after the while. (inside function gameLoop) CPP / C++ / C Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: expected primary-expression before '{' tokenThanks for that. I made those changes but that didn't correct the errors for me.
|
|
#4
|
||||
|
||||
Re: expected primary-expression before '{' tokenWhat other errors do you have now?
That was just a start, from a quick look, but there could be more. If I get a chance in a moment, I'll try a compile of what you have, but post what current code you have, so that I [or others crossing this post to assist] have the updated code. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! Last edited by TurboPT : 07-Feb-2010 at 17:58.
|
|
#5
|
|||
|
|||
Re: expected primary-expression before '{' tokenSame ones
In constructor `TicTacToe::TicTacToe()': 20 expected primary-expression before '{' token 20 expected `;' before '{' token In member function `void TicTacToe::gameLoop()': 40 expected `;' before '}' token In member function `void TicTacToe::getMove()': 181 expected primary-expression before "bool" 181 expected `;' before "bool" 229 expected primary-expression before "int" 229 expected `;' before "int" 347 `}' at end of input Makefile.win [Build Error] [TicTacToe.o] Error 1 CPP / C++ / C Code:
|
|
#6
|
||||
|
||||
Re: expected primary-expression before '{' tokenLoops will be necessary to initialize the array there. The syntax you have is correct, IF it was done at the same time when declared, but since it can't be done within the class either, the looping will be needed.
There were some other things too: 1. In validateMove(), NONE of the if's should have a ; at their end. 2. Inside both getMove() and getComputerMove() there is an else block in each function missing a closing } brace. 3. Also, [this may, or may not be a problem for your compiler] mine complains about 'row' being declared twice [at the first two loops] inside getComputerMove(). [so, if you don't get an error about 'row', then ignore #3]4. Within the output strings, the newlines should be: \n instead of: /n. Post again if more help is needed. [don't forget to repost the latest code changes] __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#7
|
|||
|
|||
Re: expected primary-expression before '{' tokenThanks. I was able to get it fixed. The ;s on the if statements were something I didn't notice. There were about 4 missing braces I kept miss counting. Now its just logic errors that I can figure out. Thanks for all of the help.
|
|
#8
|
||||
|
||||
Re: expected primary-expression before '{' tokenNo problem.
Post again, if needed. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Expected primary-expression before '{' token | Saylor | C++ Forum | 3 | 10-Nov-2009 12:42 |
| Expected primary-expression before '.' token | dinh0wjr | C Programming Language | 2 | 30-Mar-2009 12:13 |
| Error: expected unqualified-id before ‘{’ token | ftmthy412 | C++ Forum | 5 | 12-Sep-2007 16:49 |
| Converting PHP to C and I need a little help | Allenport | C Programming Language | 4 | 14-Aug-2006 13:38 |
| error: expected primary-expression before '.' token | Honourable Mist | C++ Forum | 11 | 18-Feb-2006 12:15 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The