填空题
下列程序中需要清理动态分配的数组,划线处应有的语句是 【13】 。
#include<iostream, h>
class person
{
int age, tall;
public:
person() { age= 0; tall= 40; cout<<"A baby is born. "<<end1;}
person(int i) {age=i, tall=40, cout<<"A old person. "<<end1;}
person(int i, int i) { age = i; tall = j; cout <<" a old person with tall. "<<
end1;}
~person( ) {cout<<" person dead. "<<end 1;}
void show()
{
cout<<"age= "<<age<<" ,tall= "<<tall<<end1;
}
};
void main()
{
person * ptr;
ptr = new person[3];
ptr[0]=person ( )
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3; i++)
ptr[i]. show( );
______
}
【参考答案】
delete [] ptr