Page 1 of 1

Error code question

PostPosted: Oct 5, 2003 @ 8:47pm
by gevans2000
I am trying to add a highscores table to my game using the pocket high scores system. ()

The constructor to create an instance of the CHighScores class is as follows:

CHighScores(int nMaxScores, LPCTSTR pszMagic)

I am trying to create this as a global variable of type CHighScores in my header file and use the code below to do this:

CHighScores hs(10,TEXT("TESTSTRING"));

When I compile I get the following error message:

error C2059: synatx error : 'constant'

The exact same code works fine when the CHighScores variable is declared locally within a function but following the suggestions from the authors of the library and to be able to access it from anywhere within my game, I would like to be able to make it a global variable.

Having done various searches I have failed to find an explanation of this error and being quite new to c++ I have no idea what it means. Any help would be gratefully received!!

Thanks in advance.

PostPosted: Oct 5, 2003 @ 9:46pm
by mlepage
First of all, do not *define* it in your header file like that. Do that in your source file. In the header file, *declare* it like this:

extern CHighScores cs;

Secondly, I am guessing that your syntax error is because this syntax:

CHighScores cs(10, _T("text"));

is interpreted to be a function declaration. That is, a function that returns a CHighScores, is named cs, and has its first parameter type as... the constant 10??!

See the problem?