首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。 【说明】 下面的程序实现了类String的构造函数、析构函数和赋值函数。 已知类String的原型为: class String { public:
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。 【说明】 下面的程序实现了类String的构造函数、析构函数和赋值函数。 已知类String的原型为: class String { public:
admin
2009-05-15
26
问题
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。
【说明】
下面的程序实现了类String的构造函数、析构函数和赋值函数。
已知类String的原型为:
class String
{
public:
String(coust char * str = NULL); //普通构造函数
String( const String &other); //拷贝构造函数
~String(void); //析构函数
String & operate =(const String &other); //赋值函数
private:
char * m_data; // 用于保存字符串
};
//String 的析构函数
String:: ~String (void)
{
(1);
}
//String 的普通构造函数
String: :String( const char * str)
{
if (2)
{
m_data = new char[1];
*m_data = ’\0’;
}
else
{
int length = strlen(str);
m_data = new ehar[ length + 1 ];
strepy(m_data, str);
}
}
//拷贝的构造函数
String:: String( const String &other)
{ int length = strlen(other. m_data);
m_data = new char[ length + 1 ];
strepy(m_data, other, m_data); //赋值函数
String & String::operate = (eonst String &other) //
{
if (3)
return * this;
delete [] m_clara; //释放原有的内存资源
int length = strlen( other, m_data);
m_data = new chart length + 1 ];
(4);
return (5);
}
选项
答案
(4)strcpy(m_ data,other. m_dara)
解析
在分配新的内存资源后,将other内容复制到m_data。
转载请注明原文地址:https://jikaoti.com/ti/RPW7FFFM
本试题收录于:
程序员上午基础知识考试题库软考初级分类
0
程序员上午基础知识考试
软考初级
相关试题推荐
阅读以下说明,回答问题1至问题5。【说明】某服务器既是Web站点又是FTP服务器,Web站点的域名为www.test.com,Web站点的部分配置信息如图2-1所示,FTP服务器的域名为ftp.test.com。Windo
客户小郭要求将其计算机通过电话线宽带接入Internet,则小郭的计算机通常需要添加哪些外部网络设备?除此之外,小郭还需从网络服务提供商(ISP)获得哪些信息才能宽带接入到Internet?客户小郭已经获知电子商务公司A网站服务器的IP地址。小郭可以在
阅读以下交换机配置说明,根据要求回答问题。[说明]某公司租用了一段C类地址203.12.11.0/24~203.12.14.0/24,如图7-8所示。其网间地址是172.11.5.14/24。要求公司内部网络中所有PC都能上网。
DNS是应用最广泛的主机名和IP地址的转换机制,它使用(1)来处理网络中成千上万个主机和IP地址的转换。在Linux中,DNS是由BIND软件来实现的。BIND是一个(2)系统,其中的resolver程序负责产生域名信息的查询,一个称为(3)的守护进程负责
先阅读以下说明,然后回答问题1至问题3。[说明]DHCP是动态主机配置协议,这个协议用于向计算机自动提供IP地址、子网掩码和路由信息。如果由网络管理员分配局域网上的客户机IP地址,则会费时费力且容易出错。因此采用DHCP自动分配地址,这时局
请根据图6-15网页的显示效果,解释该ASP程序中用下画线标出的语句的含义,即填写(1)、(3)、(4)、(6)、(10)空缺处的解释内容。在index.asp文档中使用了<styletype="text/css">语句。其中,CSS是指(11
在Server上进行NAT服务器配置时,若“接口2”的配置如图8-7所示,则其IP地址应设置为(1),子网掩码应设置为(2)。在WindowsServer2003操作系统中,可以通过服务器角色配置图8-6代理服务器的DHCP服务组件。在配置该企业内
在Server上进行NAT服务器配置时,若“接口2”的配置如图8-7所示,则其IP地址应设置为(1),子网掩码应设置为(2)。根据图8-6所示的拓扑结构中所给出的网络连接方式及相关的网络参数,计算机PCI得到的TCP/IP配置参数为:“IP地址
连接交换机与工作站的传输介质是什么?介质需要做成直通线还是交叉线?最大长度限制为多少?若工作站A访问外部Web服务器,发往Internet的IP包经由(1)和(2)处时源IP地址分别是什么?
随机试题
A、Itwascomplicatedbecauseofthepictures’magicpower.B、Itwasaweirdlanguagewhichonlyafewpeopleunderstood."C、Itw
引出活动主题
A.甲状腺疼痛B.宜手术治疗C.多见于老年人D.甲状腺触诊质硬淡漠型甲亢可见
A.胃液酸度升高B.胃液酸度正常或减少C.胃液酸度常减少D.胃液酸度明显升高E.胃液酸度明显减少慢性萎缩性胃窦胃炎
环境卫生学所研究的环境是
下列选项中,()按照项目占用土地而使社会成员由此损失的该土地“最佳可行替代用途”的净效益计算。
付款凭证左上角的“贷方科目”可能登记的科目是()。
继续承诺是指()。
某公司普通股目前的股价为10元/股,筹资费率为6%,刚刚支付的每股股利为2元,股利固定增长率2%,则该企业利用留存收益的资本成本为()。
根据目标管理的基本原理,在实施目标管理的全过程中,必须牢牢抓住的主线包括()。
最新回复
(
0
)