首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: using std::cout; DuDIIC: friend double distance(const Point&p); ∥p距原点的距离 Point(int XX=0,int yy=O):x
有如下程序: using std::cout; DuDIIC: friend double distance(const Point&p); ∥p距原点的距离 Point(int XX=0,int yy=O):x
admin
2019-02-22
62
问题
有如下程序:
using std::cout;
DuDIIC:
friend double distance(const Point&p); ∥p距原点的距离
Point(int XX=0,int yy=O):x(xx),y(yy){) ∥①
private:
int X,y;
double distance(const Point&p){ ∥②
return sqrt(p.X木P.x+p.Y*P.y);
)
int main(){
Point p1(3,4);
cout<
)
下列叙述中正确的是( )
选项
A、程序编译正确
B、程序编译时语句①出错
C、程序编译时语句②出错
D、程序编译时语句③出错
答案
A
解析
这段程序是正确的,计算p距离原点的距离。语句①是类Point的构造函数,在构造函数中给变量xx和yy赋初值0。语句②是计算点p距原点的距离的函数distance。语句③是计算点p1距离原点的距离并输出。
转载请注明原文地址:https://kaotiyun.com/show/JcAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序的运行结果为#include<iostream.h>voidmain(){inta=2;intb=a+1;cout<<a/b<<endl;}
在软件测试设计中,软件测试的主要目的是
在面向对象的程序设计中,类描述的是具有相似性质的一组______。
下列程序中下画线处应填入的语句是classBase{public:voidfun(){cout<<"Baseoffun"<<endl;}};classDerived:publ
设有数组定义:chararray[]="China";,则数组array所占的空间为
一个C++语言程序的开发步骤通常包括编辑、______、链接、运行和调试。
已知类A中有公用数据成员B*b;其中B为类名。则下列语句错误的是
使用静态数据成员的好处不包括
在下列关键字中,不能用来表示继承方式的是
随机试题
《巴塞尔协议》将银行资本划分为______两档。
Myson,Johnny,openedanewrestaurant,andontheopeningdayIhelpedoutinthekitchen.Bymid-morning,Inoticedthatthe
住宅室内装饰装修时,在承重外墙上开门、窗应当经()批准。
汇总记账凭证账务处理程序的优点是()。
【2014年威海市真题】心智技能培养的基本要求包括()。
Youaregoingtoreadatextaboutdifferenttypesoffriendship,followedbyalistofexamples.Choosethebestexamplefromt
What’saman?Or,indeed,awoman?Biologically,theanswermightseemobvious.Ahumanbeingisa(n)【C1】______whohasgrownfr
一个栈的入栈序列是1,2,3,…,n,其输出序列为P1,P2,P3,…,Pn,若p1=n,则Pi为()。
DictationListentothepassage.Forquestions21—25,fillintheblankswiththeexactwordsorphrasesyouhear.Inrecentyea
A、Pickasimilarcampaigntojoin.B、Learnmoreaboutenvironmentalprotection.C、Jointhewoman’scampaign.D、Launchanotherca
最新回复
(
0
)