< p >
delete()
运算符是否也会销毁对象的所有子对象?
或者在删除父对象之前,我需要调用子对象的 delete() 吗?
class equipment
{
public:
int model_id;
...
}
class player
{
public:
int x, y;
equipment * Equipment;
player(void) { Equipment = new equipment[2];};
~player(void) { delete [] Equipment; }
};
int main (....)
{
player = new Player;
...
...
delete Player;
}