首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。 【说明】 下面的程序实现了类String的构造函数、析构函数和赋值函数。 已知类String的原型为: class String { public:
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。 【说明】 下面的程序实现了类String的构造函数、析构函数和赋值函数。 已知类String的原型为: class String { public:
admin
2009-05-15
25
问题
阅读下列程序说明和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);
}
选项
答案
(3)this = =&other
解析
检查自赋值,若this和&other相同,则直接返回*this。
转载请注明原文地址:https://kaotiyun.com/show/ZwjZ777K
本试题收录于:
程序员上午基础知识考试题库软考初级分类
0
程序员上午基础知识考试
软考初级
相关试题推荐
设计该电子商务网站时,某页面框架代码如下。该网页代码中定义了(1)个框架。下面是用户登录检查的部分程序,要求实现对用户提交的用户名和密码进行检验,如果用户名、密码错误,提示错误并返回首页;如果用户名和密码正确,将用户提交的用户名(use
阅读以下技术说明和程序代码,根据要求回答问题。[说明]某公司用ASP+SQLServer开发的电子商务网站系统,提供了商品查询、网上购物车、订单管理、后台商品管理和在线支付等功能。图6~11是用ASP实现的电子商务网站的主页。系统的数据库
以下(1)是WindowsServer2003的Internet信息服务(IIS)管理器新增的服务功能。在WindowsServer2003操作系统中,邮件服务器中通过域来提供邮件服务。通常,域用户信息存储于(2)中。(1)A.WWW服
客户小郭要求将其计算机通过电话线宽带接入Internet,则小郭的计算机通常需要添加哪些外部网络设备?除此之外,小郭还需从网络服务提供商(ISP)获得哪些信息才能宽带接入到Internet?据报道,“网络天空(W32.Netsky.B)”是一种电子邮件
在一台计算机上安装完成WindowsServet2003服务器及相应的服务组件。网络中有一台客户机只安装了TCP/IP协议,能够通过网上邻居看到局域网内其他客户机和服务器,但无法访问Internet(通过IP地址也不行),但其他客户却可以,请问最有
请根据图6-15网页的显示效果,解释该ASP程序中用下画线标出的语句的含义,即填写(1)、(3)、(4)、(6)、(10)空缺处的解释内容。在index.asp文档中使用了<styletype="text/css">语句。其中,CSS是指(11
根据图6-14网页的显示效果图,请将index01.asp文件中(1)~(7)空缺处的内容填写完整。以下是该出版社用户登录页面(参考图6-14网页的右上角)的部分代码,基本功能是检测用户是否填写用户名,如果没有填写,将跳出提示错误的窗口,否则提交用户信
在Server上进行NAT服务器配置时,若“接口2”的配置如图8-7所示,则其IP地址应设置为(1),子网掩码应设置为(2)。在图8-6所示的拓扑结构中,计算机PC2(假设分配到的IP地址为192.168.0.35)访问www.ceiaec.org网站
连接交换机与工作站的传输介质是什么?介质需要做成直通线还是交叉线?最大长度限制为多少?若工作站A访问外部Web服务器,发往Internet的IP包经由(1)和(2)处时源IP地址分别是什么?
随机试题
一个串联反馈式稳压电路由________电路、________电压、________电路、________电路和________器件等几个部分组成。
为在Word文档中利用已有的数据表建立统计图,要选用_______。
下列各项中,属于行政授权的是( )。
Ifsustainablecompetitiveadvantagedependsonwork-forceskills.Americanfirmshaveaproblem.Human-resourcemanagementisno
《中华人民共和国反垄断法》已于2008年8月1日实施。在《反垄断法》草案的制定过程中,一方面,参照国际惯例,对典型的、世界各国有普遍共识的严重限制、排除竞争的行为加以严格禁止;另一方面,针对我国市场竞争不充分、企业竞争力不强的实际情况,在制度安排上努力做到
我国境内已知的最早人类是生活在距今约( )万年的元谋猿人。
Inthe400sBC,theSophists,agroupofwanderingteachers,begantoteachinAthens.TheSophistsclaimedthattheycouldteac
ToliveintheUnitedStatestodayistogainanappreciationforDahrendorf’sassertionthatsocialchangeexistseverywhere.T
A、theDoharoundcan’tbefinishedby2006B、strongpoliticalwillisnecessaryC、nationscancontinuethenegotiationevenift
Noteveryonelikestobeflattered,______?
最新回复
(
0
)