首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Point{ int x,y; public: Point(int
有如下程序: #include using namespace std; class Point{ int x,y; public: Point(int
admin
2021-07-02
46
问题
有如下程序:
#include
using namespace std;
class Point{
int x,y;
public:
Point(int x1=0, int y1=0):x(x1),y(y1) {}
int get() {return x+y;}
};
class Circle{
Point center;
int radius;
public:
Circle(int cx, int cy, int r):center(cx,cy),radius(r) {}
int get() {return center.get()+radius;}
};
int main() {
Circle c(3,4,5);
cout<
return 0;
}
运行时的输出结果是
选项
A、5
B、7
C、12
D、9
答案
C
解析
本题考查构造函数,题目中定义了Circle类,在类体中又定义了Point的对象,执行Circle c(3,4,5);后输出三个数之和,所以是12,C选项正确。
转载请注明原文地址:https://kaotiyun.com/show/oefp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;intmain(){intsum=0;for(inti=0;i
有如下两个类定义:classXX{private:doublex1;protected:doublex2;public:doublex3;};classYY
判断一个字符串是否是回文串的递归函数定义如下:boolhuiwen(strings){intn=s.length();if(n
有如下程序:#includeusingnamespacestd;classA{public:A(){cout
有如下类定义:classTest{intx一,y一;public:Test():a=(0),b—f0){}Test(inta,intb=0):a=(a),b=(b){));若
下面不属于软件设计阶段任务的是()。
以下程序的执行结果是()。#include<iostream.h>#include<iomanip.h>voidfun(intn){if(n!=0){fun(n-1);
随机试题
A.耳前淋巴结B.颌下淋巴结C.颌上淋巴结D.颏下淋巴结E.耳后淋巴结前牙及口底炎症主要引流至
既可治血虚萎黄、心悸、失眠、月经不调,又可治肾阴不足,潮热、盗汗、遗精等的药物是
固体制剂在规定的介质中,以规定方法进行检查,崩解溶散并通过规定孔径的筛网所需时间的限度,一般称为
发生粉尘爆炸的首要条件是()。
土石坝工作面的划分,应尽可能()。
以下片段选自某课堂实录,请分析该教学片段并回答下列问题:(1)该片段体现了哪种语法教学方法?(2)常见的语法教学方法有哪些?(3)语法教学的课堂模式主要有哪些?教学中应该遵循哪些语法教学的原则?教学片段:老师:同学们上午好!今天我们来讲宾语补足语
围绕组织目标,制定实施方案,在政府管理运行中所处的阶段为()。
Youwillhearfiveshortpieces.Foreachpiecedecidehowmuchisthetotalamountthespeakeristalkingabout.Writeonelett
Whatwasthesituationoftheindependentfilmproducers?
WhenIwasatschool,my【B1】______wastobeapilotintheairforce.Butmyeyesightwasn’tgoodenough.SoIhadtogiveuptha
最新回复
(
0
)