![]() |
|
#1
|
|||
|
|||
Expected primary-expression before '{' tokenI had to create a class that would accept a user input number between 0 and 9999 and translate it into "zero" to "nine thousand nine hundred ninety - nine". I had to use one int number and use static arrays to hold the strings. The problems arise when I try to initiallize the arrays. I originally had them initialized in the class when they were declared, but I saw a post saying that it would not work in C++, so I tried initializing them in the constructor, but I'm getting two errors for each array line: "expected-primary expression before '{' token" and "expected ';' before '{' token". Any help? Thanks in advance.
CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: Expected primary-expression before '{' tokenThey cannot be initialized like that. Try:
CPP / C++ / C Code:
CPP / C++ / C Code:
|
|
#3
|
|||
|
|||
Re: Expected primary-expression before '{' tokenCPP / C++ / C Code:
and CPP / C++ / C Code:
in the constructor, but now I get these errors: Numbers.h: No such file or directory. 28 expected primary-expression before ']' token 28 expected primary-expression before '{' token 28 expected `;' before '{' token 29 redeclaration of `const char Numbers::tens[]' Any help? |
|
#4
|
|||
|
|||
Re: Expected primary-expression before '{' tokenFor starters, this stuff...
CPP / C++ / C Code:
Your .cpp file needs to have #include "Numbers.h at the top. From the code you posted, it does not. Go ahead and post the ENTIRE code so that we can really see what you did. Use separate tags for the various files like I did. As far as the error message goes, it looks like it is saying that it can't find the file Numbers.h. |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Expected primary-expression before '.' token | dinh0wjr | C Programming Language | 2 | 30-Mar-2009 13:13 |
| main.cpp:15: error: expected primary-expression before ',' token | DingbatCA | C++ Forum | 8 | 29-Oct-2007 13:52 |
| Error: expected unqualified-id before ‘{’ token | ftmthy412 | C++ Forum | 5 | 12-Sep-2007 17:49 |
| Converting PHP to C and I need a little help | Allenport | C Programming Language | 4 | 14-Aug-2006 14:38 |
| error: expected primary-expression before '.' token | Honourable Mist | C++ Forum | 11 | 18-Feb-2006 13:15 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The