Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

static aabb

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

#ifndef __aabb__h_
#define __aabb__h_
#include <d3dx9.h>

class Aabb 
{
public:
 	D3DXVECTOR3		m_min;
	D3DXVECTOR3		m_max;

	Aabb();
	Aabb(D3DXVECTOR3 min, D3DXVECTOR3 max);
	Aabb(bool b);
	~Aabb(){}
         .............
};
Aabb::Aabb()
{
	empty();
}

#endif // #ifndef __Aabb__h_

I found static Aabb; actually call default constructor in stead of set all data to 0 is that true?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ToohrVyk
Yes. Data is always initialized with a constructor. If none is specified, the default one is used.


but c++ primer said static variable is initial with 0 if you do not explicit initial.

Share this post


Link to post
Share on other sites
That is because static data declared in a class is almost "outside" the class. To initialise static data, you initialise it at the point of... well, you initialise it in the source file, not the header file. At the point of resolution? Anyway:


//header_file.h
class Chicken
{
public:
static int number_of_chickens;
}

//source_file.cpp
#include "header_file.h"
// we start with 17 chickens
int Chicken::number_of_chickens = 17;

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!