首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: CMyObject,in the construtor ~CMyObject,in the destru
使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: CMyObject,in the construtor ~CMyObject,in the destru
admin
2017-03-22
23
问题
使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为:
CMyObject,in the construtor
~CMyObject,in the destrutor
注意:错误的语句在//********error********的下面,修改该语句即可。
#include
class CMyObject
{
//********error********
//********error********
CMyObject{cout<<"CMyObject,
in the constrUtor"<
~CMyObject(){cout<<
"~CMyObject,in the destrutor"
<
};
Void main()
{
CMyObject obj1;
}
选项
答案
(1)添加语句:public: (2)CMyObject(){cout<<"CMyObject,in the construtor"<
解析
(1)构造函数和析构函数均为公有函数,而在C++中默认的访问属性为私有(private),因此构造函数和析构函数必须说明为public,即第1个标识下应添加“public:”。
(2)函数定义中在函数名后均有一对括号表示函数声明,因此第2个标识下应改为“ CMyObjectO{cout<< "CMyObject,in theconstrutor"<
转载请注明原文地址:https://kaotiyun.com/show/39Ap777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
对于语句cin>>x中的各个组成部分,下列叙述中错误的是
数据库设计包括两个方面的设计内容,它们是
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用;请补充完整。classcomplex{private:intreal;iht
在下面横线上填上适当的语句,完成程序。#include<iostream>usingnamespacestd;classBase{intx;public:
以下程序中调用cin函数给变量a输入数值的方法是错误的,其错误原因是#include<iostream.h>voidmain(){int*p,*q,a,b;p=&a;
有如下循环语句:for(inti=50;i>20;i-=2)eout
计算斐波那契数列第n项的函数定义如下:intfib(intn){if(n==0)return1;elseif(n==1)return2;elsereturnfib(n-1)+ilb(n-2);}若执行函数调用表达式fib(
有如下两个类定义:classAA{};classBB{AAv1,*v2;BBv3;int*v4;};其中有一个成员变量的定义是错误的,这个变量是
随机试题
储气罐高压表下限为()KPa。
有关计算烧伤患者热能需要量时,下列说法不正确的是
A.病邪入里B.寒邪化热C.邪退正复D.热退津复E.湿热留恋舌苔由薄白转为白厚,提示()
分类账簿按反映内容的______不同,分为总分类账和明细分类账。
儿童在周岁时只会咿呀学语,到三四岁时多半说话流畅了,这说明年龄决定儿童的心理发展。()
一、注意事项1.申论考试,与传统作文考试不同,是对分析驾驭材料的能力与对表达能力并重的考试。2.作答参考时限:阅读资料40分钟,作答110分钟。3.仔细阅读给定的资料,按照后面提出的“申论要求”依次作答。二、给定材料1.国家助学
A.Nokiaposts$1.38bnlossinthefourthqtrB.Goldsurgesto7-weekhighof$1,720C.R-PowerropesinGermanutilit
甲在缓刑考验期内犯罪,但在缓刑考验期满后才被发现,且未过追诉时效,对甲的处理应该是()。
有如下类定义:classCup{public:voidSetPrice(doubleval=5.8);doubleGetPrice(){returnprice;
「まどしめましょうか。」「いいえ、あついから________いいですよ。」
最新回复
(
0
)