首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class Boat; class Car{ public: Car(int i):weight(i){}
有如下程序: #include<iostream> using namespace std; class Boat; class Car{ public: Car(int i):weight(i){}
admin
2017-11-28
61
问题
有如下程序:
#include<iostream>
using namespace std;
class Boat;
class Car{
public:
Car(int i):weight(i){}
Mend int Total(const Car&c,const Boat&b);//①
private:
int weight;
};
class Boat{
public:
Boat(int i):weight(i){}
Mend int Total(const Car&c,const Boat&b);
private:
int weight;
};
int Total(const Car&c,const Boat&b){ //②
return c.weight+b.weight;
}
int main(){
Car c(10);
Boat b(8);
cout<<’’The total weight is’’<<Total(c,b)<<endl;//③
return 0;
}
下列关于程序的描述中,正确的是( )。
选项
A、程序编译正确
B、程序编译时语句①出错
C、程序编译时语句②出错
D、程序编译时语句③出错
答案
A
解析
程序中定义了类Car和类Boat,在两个类中分别定义他们的构造函数和友元函数friend。程序在VC6.0中编译通过。
转载请注明原文地址:https://kaotiyun.com/show/b3Ap777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于构造函数的叙述错误的是( )。
数据库系统的核心是
在C++中,打开一个文件,就是将这个文件与一个()建立关联;关闭一个文件,就是取消这种关联。
常用的软件结构设计工具是结构图(SC),也称程序结构图。其中,用矩形表示______,用带空心圆的箭头表示传递的是数据。
用树形结构表示实体之间联系的模型是
下列函数原型声明中,错误的是
在结构化分析方法中,数据字典的作用是
在程序设计阶段应该采取______和逐步求精的方法,把一个模块的功能逐步分解,细化为一系列具体的步骤,进而用某种程序设计语言写成程序。
对如下二叉树进行后序遍历的结果为()。
需求分析阶段的任务是()。
随机试题
我国《法制日报》对法律所作的解释是_____________。
简述王明“左”倾教条主义的主要错误及其危害。
纤溶酶的主要作用是
下列药,擅治阳明经头痛的是
依据法律规定,债务人未向第三人履行债务或者履行债务不符合约定,应()。
—Emma,thanksfor______meyourpen.—You’rewelcome.
Accordingtoarecentsurvey,teachersarenotanymoreconsideredasgoodexamplesforstudents.Thelatterconsiderthattheb
“着色”的“着"应读作()。
Hurricanesareviolentstormsthatcausemillionsofdollarsinpropertydamageandtakemanylives.Theycanbeextremelydange
NowintheU.S.thewomenworkingoutsidehomecanget______.Theexpression"full-timehousework"inparagraph2means______
最新回复
(
0
)