I encountered a strange problem:class memory alignment

In CUDA program, when I wrote the class like this:

class ensemble_model
{
public:
	ensemble_model(void);
	~ensemble_model(void);

	int model_type;   

	unsigned int feature_dim;   
	unsigned int rand_dim;  
	unsigned int num_classifiers;  
	model **models_pt; 
	matrixindex **rand_index; 
	double negative_label;  
	double positive_label;  
	NDmatrix *mean; 
	NDmatrix *Std_variance; 
	bool standlize_type; 
	int checkpara(void);   

	 
	unsigned int h_min;   
	unsigned int h_max;  
	unsigned int h_refer; 
	unsigned int w_min;   
	unsigned int w_max;    
	unsigned int w_refer;  
	double qtable[64];       
	double qtable_factor;  
	double qtable_previous[64];  
	double qtable_prev_factor;  
	double texture_complex;   

};

When the members of a class assignment and data read again,the addresses of these data members will go wrong:

	unsigned int h_min;   
	unsigned int h_max;  
	unsigned int h_refer; 
	unsigned int w_min;   
	unsigned int w_max;    
	unsigned int w_refer;  
	double qtable[64];       
	double qtable_factor;  
	double qtable_previous[64];  
	double qtable_prev_factor;  
	double texture_complex;   

After that I exchange position of the two data sets, like this:


class ensemble_model
{
public:
	ensemble_model(void);
	~ensemble_model(void);

	int model_type;   

	unsigned int h_min;   
	unsigned int h_max;  
	unsigned int h_refer; 
	unsigned int w_min;   
	unsigned int w_max;    
	unsigned int w_refer;  
	double qtable[64];       
	double qtable_factor;  
	double qtable_previous[64];  
	double qtable_prev_factor;  
	double texture_complex;   
	
	unsigned int feature_dim;   
	unsigned int rand_dim;  
	unsigned int num_classifiers;  
	model **models_pt; 
	matrixindex **rand_index; 
	double negative_label;  
	double positive_label;  
	NDmatrix *mean; 
	NDmatrix *Std_variance; 
	bool standlize_type; 
	int checkpara(void);    

};

When the members of a class assignment and data read again,the addresses of these data members will also go wrong:

	unsigned int feature_dim;   
	unsigned int rand_dim;  
	unsigned int num_classifiers;  
	model **models_pt; 
	matrixindex **rand_index; 
	double negative_label;  
	double positive_label;  
	NDmatrix *mean; 
	NDmatrix *Std_variance; 
	bool standlize_type; 

Finally, I adjust the structure to this:

class ensemble_model
{
public:
	ensemble_model(void);
	~ensemble_model(void);
	int checkpara(void); 

	double qtable[64];       
	double qtable_factor;  
	double qtable_previous[64];  
	double qtable_prev_factor;  
	double texture_complex; 
	double negative_label;  
	double positive_label;  	
	unsigned int h_min;   
	unsigned int h_max;  
	unsigned int h_refer; 
	unsigned int w_min;   
	unsigned int w_max;    
	unsigned int w_refer;  
	unsigned int feature_dim;   
	unsigned int rand_dim;  
	unsigned int num_classifiers; 
	 
	bool standlize_type; 
	int model_type;   
	model **models_pt; 
	matrixindex **rand_index; 

	NDmatrix *mean; 
	NDmatrix *Std_variance;  

};

This time, the class member data address is right. But I don’t know why, anyone can explain this?