首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: using namespace std; class Car{ public: Car(int i):weight(i){) friend int Total(const Car&c,const Bo
有如下程序: using namespace std; class Car{ public: Car(int i):weight(i){) friend int Total(const Car&c,const Bo
admin
2020-11-11
33
问题
有如下程序:
using namespace std;
class Car{
public:
Car(int i):weight(i){)
friend int Total(const Car&c,const Boat&b); ∥①
private:
class Boat{
public:
Boat(int i):weight(i){)
friend int Total(const Car&c,const Boat&b);
private:
int weight;
int Total(const Car&c,const Boat&b){ ∥②
retum c.weight+b.weight;
}
int main(){
Car c(10);
cout<<"The total weight is"<
return 0:
)
下列关于程序的描述中,正确的是( )。
选项
A、程序编译正确.
B、程序编译时语句①出错
C、程序编译时语句②出错
D、程序编译时语句⑨出错
答案
A
解析
程序中定义了类Car和类Boat,在两个类中分别定义他们的构造函数和友元函数friend。程序在’VC6.0中编译通过。
转载请注明原文地址:https://kaotiyun.com/show/uSyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
数据库设计的四个阶段是:需求分析、概念设计、逻辑设计和()。
使用输入输出操作符setw,可以控制()。
有如下程序:#include<iostream>usingnamespacestd;intmain(){voidfunction(doubleval);doubleval;f
有如下程序:#include<iostream>usingnamcspacestd;voidfunction2(intn);voidfunctionl(intn){if(n<=0)return;
为类Matrix重载下列运算符时,只能作为Matrix类成员函数重载的运算符是()。
下列运算符函数中,肯定不属于类Value的成员函数的是()。
执行下列语句段后,输出字符“*”的个数是()。for(inti=50;i>1:——i)cout<<’*’;
在E—R图中,用来表示实体联系的图形是()。
下列符号中不属于C++关键字的是
设表的长度为n。存下列结构所对应的算法中,最坏情况下时间复杂度最低的是
随机试题
肾结核的主要传播途径是
睡时汗出,醒则汗止,属于()
有机磷农药中毒的主要作用机制是()
某公司“盈余公积”科目的年初余额为900万元,本期提取盈余公积1112.5万元,用盈余公积转增资本500万元。该公司“盈余公积”科目的年末余额为()万元。
2008年全国共查处广告违法案件51599件,下降8.88%;罚没金额2.47亿元,比上年同期减少2528.90万元,下降9.30%。其中共查处虚假广告14150件,比上年同期减少2234件,下降13.64%;非法经营广告9694件,其他广告违法案件277
Dopeoplestoponcetheyhaveachievedsomething?No!Inlife,wearealwaystryingtodothingsbetterorhavingmoreofthesam
假定在窗体上添加了一个通用对话框控件,其名称为CD1,并有如下程序段:CD1.ShowOpen:CD1.DefaultExt="doc"在打开文件的对话框中选择了"c:\filel.txt"文件,则FileTitle属性的值是
Pollutionisa"dirty"word.Topollutemeanstocontaminate-topsoilorsomethingbyintroducingimpuritieswhichmake【C1】______
HongKongHarborCruiseByNightEnjoyyourwonderfuldinnerontheferryandseethefantasticcitylightsTime:7:00
ScientistssaytheyhavehighhopesforadrugthatcouldonedayprovideanewformoftreatmentforHIV-AIDS.Acompound,whic
最新回复
(
0
)