Archived

This topic is now archived and is closed to further replies.

Dwiel

const static int....

Recommended Posts

Dwiel    365
Am I just being stupid or what? All I want is a const variable that is shared by every class of the type... a static const. When I have something like: static const int maxnumofbots = 20; the compiler saays that only '= 0' can follow... so where would I put the value I want this variable to hold? [EDIT] This variable IS in a class not sure if it was obvious by only indirectly mentioning this [/EDIT] Thanx! Dwiel [edited by - Tazzel3d on March 6, 2003 4:42:47 PM]

Share this post


Link to post
Share on other sites
dalleboy    324
Your compiler is not standard compliant, what compiler are you using. Do it like this instead:

Definition file (.h):
class theclass
{
static const int maxnumofbots;
};


Implementation file (.cpp):
const int theclass::maxnumofbots = 20;

Or you could do like this in the definition file (.h):
class theclass
{
enum { maxnumofbots = 20 };
};




Update GameDev.net system time campaign - success at last

Share this post


Link to post
Share on other sites
Dwiel    365
Hey guys, thanx for the help. When I put the variable decleration in the cpp file, everything worked well...

I wish I could have it in the header though where all of that other stuff is...

I''m using MSVC++ 6.0

Thanx again for the help!

Dwiel

Share this post


Link to post
Share on other sites