问答题
阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。<br>【说明】Point是平面坐标系上的点类,Line是从Point派生出来的直线类。<br>include <iostream.h><br>class Point<br>{public:<br>Point (int x, int y) ;<br>Point (Point &p) ;<br>~Point();<br>void set (double x, double y) ;<br>void print();<br>private:double X,Y;<br>};<br>Point::Point (int x, int y) //Point 构造函数<br>{X=x; Y=y; }<br>Point::Point ((1) ) //Point 拷贝构造函数<br>{X=p.X; Y=p.Y;}<br>void Point::set (double x, double y)<br>{X=x; Y=y; }<br>void Point::print()<br>{cout<<' ('<<X<<","<<Y<<") "<<endl; }<br>Point::~Point()<br>{cout<<"Point 的析构函数被调用! "<<endl;<br>class Line: public Point<br>{public:<br>Line (int x, int y, int k) ;<br>Line (Line &s) ;<br>~Line();<br>void set (double x, double y, double k)<br>void print();<br>private:double K;<br>};<br>(2)//Line 构造函数实现<br>{ K=k;}<br>(3)//Line 拷贝构造函数实现<br>{K=s.K;}<br>void Line::set (double x, double y, double k)<br>{ (4);<br>K=k;<br>}<br>void Line::print()<br>{cout<<" 直线经过点";<br>(5);<br>cout<<"斜率为: k="<<K<<endl;<br>}<br>Line: :~Line()<br>{cout<<"Line 析构函数被调用! "<<endl;<br>}<br>void main()<br>{Line 11 (1,1,2) ;<br>11 .print();<br>Linel2 (11) ;<br>12.set (3,2,1) ;<br>12.print();<br>}
套餐购买该问题答案仅对会员开放,欢迎开通会员 ¥ 19.9
0.64/天
1个月(不限次)
¥ 19.9
1000次
(不限时)
¥ 29.9
0.32/天
3个月(不限次)
¥ 59.9
0.16/天
1年(不限次)
立即支付