首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序中需要清理动态分配的数组,划线处应有的语句是【 】。 #include<iostream, h> class person { int age, tall; public: person() { age= 0; tall= 40; co
下列程序中需要清理动态分配的数组,划线处应有的语句是【 】。 #include<iostream, h> class person { int age, tall; public: person() { age= 0; tall= 40; co
admin
2010-06-06
50
问题
下列程序中需要清理动态分配的数组,划线处应有的语句是【 】。
#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
. show( );
______
}
选项
答案
delete [] ptr
解析
本题考察对象数组的销毁方法,注意删除对象数组时,[]内不要指定大小。
转载请注明原文地址:https://kaotiyun.com/show/Mwjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若有以下程序段:charstr[4][12]:{"aaa","bbbb","cccec","dddddd"},*strp[4];inti;for(i=0;i<4;i++)strp[i]=str[i];则以下错误引用字符串的选项是
有以下程序:#includemain(){intc;while((c=getchar())!=’\n’{switch(c-‘3’){case0:case1:putc
已知函数的调用形式:fread(buffer,size,count,fp);其中buffer代表的是()。
学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fun,它的功能是:把高于等于平均分的学生数据放在b所指的数组中,高于等于平均分的学生人数通过形参n传回,平均分通过函数值返回。注意:部分源程序在文件PROG1.
若语句“t=fun(x,y,a),(a+b,a+c),x+y+z);”对fun函数的调用正确,则fun函数的形参个数为()。
有以下程序:#include<stdio.h>main(){ints[12]={1,2,3,4,4,3,2,1,1,1,2,3},c[5]={0},i;for(i=0;i<12;i++)c[s[i]]++;for(i=1;i<5;i++)
在下列叙述中,错误的是()。
开发大型软件时,产生困难的根本原因是()。
随机试题
回收站用来保存被删除的文件,因此它不占用硬盘的空间。()
PlayingorganizedsportsissuchacommonexperienceintheUnitedStatesthatmanychildrenandteenagerstakethemforgranted
德育过程有哪些基本规律?
革兰阳性菌和革兰阴性菌细胞壁的共同成分是
体格发育最快的时期是
某堤防工程,其保护对象的防洪标准为50年,该堤防工程级别为()级。
“备案号”栏:()。“合同协议号”栏:()。
下列有关审计人员选择审计标准的做法,错误的是()。
教育史上两大对立学派——传统教育理论和现代教育理论的代表人物分别是——和——。
TheHistoryofChineseAmericans[A]ChinesehavebeenintheUnitedStatesforalmosttwohundredyears.Infact,theChines
最新回复
(
0
)