Jump to content
  • Advertisement
Sign in to follow this  
deEnumerator

const init within a class

This topic is 4610 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

MSVC8 express wont let me compile with the constant, BALL_VELOCITY outside of the initializer list(like below). Is it something im doing wrong, or this a rule? Ball::Ball(int bv)
{
	pBallBitmap = SDL_LoadBMP("ball.bmp");
	SDL_SetColorKey(pBallBitmap, SDL_SRCCOLORKEY, SDL_MapRGB(pBallBitmap->format, 255,0,255));

	mBallRect;                       //rect for bitmap position info
	mBallRect.x = 6;
	mBallRect.y = 6;
	mBallRect.w = 14;
	mBallRect.h = 14;
	mpBallRect = &mBallRect;         //pointer to ballrect

	BALLx = 300;
	BALLy = 400;
	BALL_VELOCITYx = bv; // or BALL_VELOCITYx = 500; ?
	BALL_VELOCITYy = bv; // or BALL_VELOCITYy = 500; ?
	ballVelx = 0;
	ballVely = -1;
}

Share this post


Link to post
Share on other sites
Advertisement
It's a rule; non-static constant members must be initialized in the member initialization list.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!