Jump to content
  • Advertisement

Archived

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

Dwiel

const static int....

This topic is 5587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
I didn''t think it actually supported any initialization within the class declaration... does it?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!