首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正其中的错误,使程序正常运行,并且输出以下结果: (4,5) 7,8 (4,8) 注意:错误的语句在 ∥********error******
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正其中的错误,使程序正常运行,并且输出以下结果: (4,5) 7,8 (4,8) 注意:错误的语句在 ∥********error******
admin
2017-09-20
49
问题
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正其中的错误,使程序正常运行,并且输出以下结果:
(4,5)
7,8
(4,8)
注意:错误的语句在 ∥********error********的下面,修改该语句即可。
#include
class cobj0
{
public:
cobj 0(int i,int j)
{
x=i;
y=j;
}
∥********error********
virtual void m0Ve(int a;int b)
{
x+=a;
y+=b;
}
void print()
{
cout<<“(”<
<<”}”<
}
public:
int x,y;
};
class cobj 1:public cobj 0
(
public:
∥********error********
cobj 1(int i,int j,int k):(i,j)
{
m=k;
n=1;
}
void print()
{
cout<
}
void func()
{
move(3,5);
}
void display()
{
∥********error********
print();
}
private:
int m,n;
};
void main()
{
cobj 0 oh3(4,5);
obj.print();
cobj 1 obj 1(1,3,7,8);
obj 1.func();
obj 1.print();
oh3 1.display();
}
选项
答案
(1)virtual void move(int a,int b) (2)CObj 1(int i,int j,int k,int 1): CObj 0(i,j) (3)CObj 0::print();
解析
程序中定义了COhj0和CObj1两个类,CObj1公有派生于CObj0,CObj0有两个public成员变量X和y,CObj1有2个private成员变量m和n,CObjO的print函数打印x和y的值,CObj 1的print函数打印m和n的值,display函数调用基类的print函数打印CObj 1的x和y的值。
转载请注明原文地址:https://kaotiyun.com/show/FTAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下不属于构造函数特征的是。
设有以下类的定义: class Ex { int x; public: void setx(int t=0); }; 若在类外定义成员函数setx(),以下定义形式中正确的是
语句cout<<(a=2)&&(b=-2);的输出结果是
下列关于软件设计基本原理的叙述中错误的是
下列程序的输出结果为2,请将程序补充完整。#include<iostream>usingnamespacestd;classBase{public:______voidfun(){cout<<
阅读下列程序:#include<iostream.h>voidfun(intn){intx(5);staticinty(10);if(n>0){++x;++y;cou
下列有关内联函数的叙述中,正确的是()。
定义如下枚举类型:enum{Monday,Tuesday,Wednesday,Thursday,Friday=2};表达式Wednesday==Friday的值是()。
若类A和类B的定义如下:#include<malloc.h>classA{inti,j;public:intgeti(){returni;}};classB:
随机试题
将习近平新时代中国特色社会主义思想载入宪法的是()
A、阿司匹林B、保泰松C、吲哚美辛D、扑热息痛E、双氯芬酸治疗类风湿关节炎的首选药物是
根据社会保险法律制度的规定,下列不属于由工伤保险基金负担的工伤保险待遇的是()。
按照《公司法》规定,物业服务企业为股份有限公司的,注册资本不得低于()万元。
绿色消费是指消费者对绿色产品的需求、购买和消费活动,是一种具有生态意识的、高层次的理性消费行为。()
Consumersandproducersobviouslymakedecisionsthatmoldtheeconomy,butthereisathirdmajor【C1】______toconsidertherole
GrayingPopulationStaysinthePinkA)Elderlypeoplearegrowinghealthier,happierandmoreindependent,sayAmericanscientis
Haveyouevermadeaprofitfromwalkingadog?Doyoulikeworkingaloneoringroups?Haveyoueversetaworldrecordinanyt
A、Hefeltuneasywiththejob.B、Hedidn’tliketotravelabroad.C、Hewasnotsatisfiedwiththesalary.D、Hefeltthejobwas
A、Ithasbeenthebestsellerforweeks.B、Itadvisespeopletochangethemselves.C、Itisbeingsoldataverylowprice.D、Itd
最新回复
(
0
)