クラス内で動的構造体と unsigned char 配列を宣言する適切な方法は何ですか?
#define GENDER_MALE 0
#define GENDER_FEMALE 1
class c_House {
public:
c_House();
c_House( unsigned int in_BedRoomCount,
short in_FloorCount,
const char* in_Address,
unsigned int in_PeopleCount ) :
BedRoomCount( in_BedRoomCount ),
FloorCount( in_FloorCount ),
Address( in_Address ),
PeopleCount( in_PeopleCount )
{
this->Array = new unsigned char[ in_BedRoomCount ];
this->People = new PEOPLE[ in_PeopleCount ];
};
~c_House() { delete[] this->Array; };
// PROPERTIES
private:
struct PERSON {
unsigned short Age;
const char* Name;
unsigned short Gender;
};
unsigned int BedRoomCount;
short FloorCount;
const char* Address;
unsigned char* Array;
unsigned int PeopleCount;
PERSON *People;
// ACTIONS
private:
void OpenGarage( bool in_Open );
void Vacuum();
};
動的配列 (int および struct) を宣言するにはどうすればよいですか? 私はこれが非常に危険であることを知っています - ディープコピーなどについて考えてください:
this->Array = new unsigned char[ in_BedRoomCount ];
this->People = new PEOPLE[ in_PeopleCount ];
これは int 配列を削除する正しい方法ですか?
~c_House() { delete[] this->Array; };
構造体配列はどうですか?