题目内容 (请给出正确答案)
[主观题]

已知有如下类Point的声明: class Point { int x,y; public: Point(int px=0,int py=0); Point(Po

已知有如下类Point的声明: class Point { int x,y; public: Point(int px=0,int py=0); Point(Point &p); }; Point::Point(int px,int py):x(px),y(py) { cout<<’(’<> <<","<> <<’)’; } point::point(point &p) { x="p.x;" y="p.y;"> <<","<> <<’)’; } 若执行以下语句,将会输出 。 point p1(10,5),p2(p1),*pt; pt="new" point; delete pt;>

提问人:网友linpeng12315 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“已知有如下类Point的声明: class Point { …”相关的问题
第1题
有如下程序:

#include

usingnamespacestd;

classPoint{

intX,Y;

public

point(intx1=0,inty1=O)tx(x1),y(y1){}

intget(){returnx+y;}

};

classCircle{

pointcenter;

intradius;

public

circle(intCX,intcy,intr):center(cx,cy),radius(r)

{}

intget(){returncenter.get()+radius;)

};

intmain(){

circlec(3,4,5);

cout$amp;return0;

}

运行时的输出结果是()。

A.5

B.7

C.9

D.12

点击查看答案
第2题
有如下程序: #include usingnamespacestd; classPoint{ intX,Y; public point(intx1=0,inty1=O)tx(x1),y(y1){} intget(){returnx+y;} }; classCircle{ pointcenter; intradius; public circle(intCX,intcy,intr):center(cx,cy),radius(r) {} intget(){returncenter.get()+radius;) }; intmain(){ circlec(3,4,5); cout$amp;A.5

B.7

C.9

D.12

点击查看答案
第3题
类型转换函数实例: class CMyPoint { int x, y; public: CMyPoint(int i, int j) { x = i; y = j; } operator double(); //转换为到原点的距离 }; 请完成CMyPoint的类型转换函数,使(double)p;能够返回p和原点的距离。
点击查看答案
第4题
类运算符重载实例如下: class CMyPoint { int x, y; public: CMyPoint(int i, int j){ x=i; y=j; } CMyPoint operator+(CMyPoint &p) //二元运算符 {return CMyPoint(x+p.x, y+p.y);} CMyPoint operator–(CMyPoint &p) //二元运算符 {return CMyPoint(x-p.x, y–p.y);} }; p1,p2为该类的实例,则如下调用方法中,错误的是( )

A、CMyPoint p3=p1+p2;

B、operator +(p1,p2);

C、p1=p1.operator +(p2);

D、p1=p1 +(p2);

点击查看答案
第5题
有以下程序 #include "iostream" using namespace std; void point(char *p){p+=3;} int main() { char b[4]={'a','b','c','d'},*p=b; point(p); cout<<*p< return 0; } 程序运行后的输出结果是(> A、a

B、b

C、c

D、d

点击查看答案
第6题
Number类定义如下: public class Number { public int x; } swap方法定义如下: public static void swap(Number number1, Number number2) { int temp = number1.x; number1.x = number2.x; number2.x = temp; } 运行如下代码: Number number1 = new Number(); Number number2 = new Number(); Number number3 = new Number(); number1.x = 1; number2.x = 2; number3.x = 3; swap(number1, number2); swap(number2, number3); 则number1.x, number2.x, number3.x的值分别为:

A、1, 2, 3

B、2, 3, 1

C、3, 2, 1

D、1, 3, 2

点击查看答案
第7题
已知: package p; class C { public int x; } 那么,在哪种情况下可以访问 x

A、任意类

B、只有类 C

C、只有类 C 的子类

D、包 p 中的类

点击查看答案
第8题
#include <iostream> using namespace std; class Point{ public: int x, y; Point(int a, int b=1){ x=a; y=b; } Point(Point &obj){ x=obj.x; y=obj.y; } }; void main(){ Point obj1(5); Point obj2(obj1); Point obj3=obj2; cout< <obj1.y> <<”,”<> <<”,”< } 则程序运行后的输出为:(> A、5,5,5

B、5,1,1

C、1,1,1

D、1,5,5

点击查看答案
第9题
有以下定义: class point{ int m,n; public: void set(int x,int y){this->m=x;this->n=y;} }; Point *pointer; 则以下哪种使用是正确的:

A、pointer->m=3;

B、cout<<pointer-> n;

C、p->set(1,2)

D、p.set(1,2)

点击查看答案
第10题
现有分数类: class Fraction { public: Fraction(int x, int y) {fenzi = x;fenmu = y;} private: int fenzi; int fenmu; };
点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信