This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Error code question


Error code question

Postby gevans2000 » Oct 5, 2003 @ 8:47pm

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.
gevans2000
pm Member
 
Posts: 45
Joined: Jun 11, 2003 @ 6:02pm
Location: London UK


Postby mlepage » Oct 5, 2003 @ 9:46pm

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?
www.scalenesoftware.com
Great games for your Palm and Pocket PC!
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum