首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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-02-22
18
问题
有如下程序:
#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的对象,执行Circlec(3,4,5);后输出三个数之和,所以是12,C选项正确。
转载请注明原文地址:https://kaotiyun.com/show/K1fp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classONE{intc;public:ONE():c(0){cout
下列叙述中正确的是
下列关于模板形参的描述中,错误的是()。
以下程序的执行结果为()。#includeclassSample{intn:public:Sample(inti){n=i;)operator++(){n++;}//
下面关于构造函数和析构函数的描述,错误的是()。
请打开考生文件夹下的解决方案文件proj1,其中在编辑窗口内显示的主程序文件中定义有类AAA和主函数main。程序文本中位于每行“//ERROR****found****”下面的一行有错误,请加以改正。改正后程序的输出结果应该是:sum=60注意:只修
使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。完成函数ToUpper(char*des,char*str),该函数实现把str字符串中小写字符转换成大写字符,并存发在des中。例如:str=’’
某二叉树共有12个结点,其中叶子结点只有1个。则该二叉树的深度为(根结点在第1层)()。
在深度为7的满二叉树中,叶子结点的个数为
对下列二叉树进行前序遍历的结果是
随机试题
Whatcanbeinferredfromthenews?
以下情形中,经高级人民法院批准或决定,二审期限可以再延长1个月的有
Thesurfaceoftheearth______(cover)bymassesoflandandlargerareasofwater.
鉴别急性粒细胞白血病与急性淋巴细胞白血病的要点是()
FIDIC合同条件规定,由于工程变更,该项目实施的实际工程量超过或小于工程量表中所注明工程量的25%以上时,才考虑费率和价格的变动。()
以下船舶需在6级大风范围半径到达工地5h前抵达防台锚地的是()。
What’sLackingin"Sicko"?Whenitcomestoeconomicdecisions,therearealwaystrade-offs.Gainonethingandyoulosesom
TheyhavegonetoXi’an.______youever_______therebefore?
Questions5-8CompletethefollowinginformationaboutthebooksJackrecommendstoAhmedusingNOMORETHANTHREEWORDSforeac
LandfilisYouhavejustfinishedyourmealatafastfoodrestaurantandyouthrowyouruneatenfood,foodwrappers,drinkc
最新回复
(
0
)