第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于return 與 析構(gòu) 和 拷貝 問題 輸入4后輸入8個點坐標 1,2 ...

關于return 與 析構(gòu) 和 拷貝 問題 輸入4后輸入8個點坐標 1,2 ...

ReZero 2016-03-19 12:01:03
#include<iostream>using namespace std;class Point{public:? ? Point():x_(0),y_(0){cout<<"Point : (0, 0) is created."<<endl;}? ? Point(double x, double y):x_(x),y_(y){cout<<"Point : ("<<x_<<", "<<y_<<") is created."<<endl;}? ? Point(const Point &p);? ? ~Point();? ? const double x()const{return x_;}? ? const double y()const{return y_;}? ? void show()const{? ? cout << "Point : ("<<x_<<", "<<y_<<")"<<endl;? ? }? ?const void showNoEndOfLine()const{cout << "Point : ("<<x_<<", "<<y_<<")" ;}? ? double x_, y_;};Point::Point(const Point &p):x_(p.x_),y_(p.y_){cout<<"Point : ("<<x_<<", "<<y_<<") is copied."<<endl;}Point::~Point(){cout<<"Point : ("<<x_<<", "<<y_<<") is erased."<<endl;}istream &operator>>(istream &is, Point &p){? ? char z;? ? is >> p.x_ >>z>> p.y_;? ? return is;}class Line{public:? ? Line():sta_(0,0),ed_(0,0){cout<<"Line : ("<<sta_.x_<<", "<<sta_.y_<<") to ("<<ed_.x_<<", "<<ed_.y_<<") is created."<<endl;}? ? Line(double x1,double y1,double x2,double y2 ):sta_(x1,y1),ed_(x2,y2){cout<<"Line : ("<<sta_.x_<<", "<<sta_.y_<<") to ("<<ed_.x_<<", "<<ed_.y_<<") is created."<<endl;}? ? Line(Point &sta, Point &ed):sta_(sta),ed_(ed){cout<<"Line : ("<<sta_.x_<<", "<<sta_.y_<<") to ("<<ed_.x_<<", "<<ed_.y_<<") is created."<<endl;}? ? Line(const Line &z);? ? ~Line();? ? Line& setLine(double x1,double y1,double x2,double y2){? ? sta_.x_=x1;? ? ed_.x_=x2;? ? sta_.y_=y1;? ? ed_.y_=y2;? ? return *this;? ? }? ? Line& setLine(const Point &g, const Point &h){? ? sta_.x_=g.x_;ed_.x_=h.x_;? ? sta_.y_=g.y_;ed_.y_=h.y_;? ? return *this;? ? }? ? Line& setLine(const Line &k){? ? sta_.x_=k.sta_.x_;ed_.x_=k.ed_.x_;? ? sta_.y_=k.sta_.y_;ed_.y_=k.ed_.y_;? ? return *this;? ? }? ? void readLine(){cin>>sta_>>ed_;}? ? void show()const{? ? cout << "Line : ("<<sta_.x_<<", "<<sta_.y_<<") to ("<<ed_.x_<<", "<<ed_.y_<<")"<<endl;? ? }? ? Point setStart(Point &p){sta_.x_ = p.x_; sta_.y_ = p.y_;}? ? Point setEnd(Point &q){ed_.x_ = q.x_; ed_.y_ = q.y_;}//調(diào)用析構(gòu)// ? ?Point& l = sta_;// ? ?Point& o = ed_;// ? ?Point& start()const{return l;}// ? ?Point& end()const{return o;}? ? const Point& start()const{return sta_;}//調(diào)用拷貝? ? const Point& end()const{return ed_;}private:? ? Point sta_, ed_;};Line::Line(const Line &z):sta_(z.sta_),ed_(z.ed_){//wo? ? ? ? cout<<"Line : ("<<sta_.x_<<", "<<sta_.y_<<") to ("<<ed_.x_<<", "<<ed_.y_<<") is copied."<<endl;}Line::~Line(){cout<<"Line : ("<<sta_.x_<<", "<<sta_.y_<<") to ("<<ed_.x_<<", "<<ed_.y_<<") is erased."<<endl;}void showLineCoordinate(const Line& line){? ? std::cout<<"Line : ";? ? std::cout<<"("<<line.start().x()<<", "<<line.start().y()<<")";? ? std::cout<<" to ";? ? std::cout<<"("<<line.end().x()<<", "<<line.end().y()<<")";? ? std::cout<<std::endl;}void showLinePoint(const Line& line){? ? std::cout<<"Line : ";? ? line.start().showNoEndOfLine();? ? std::cout<<" to ";? ? line.end().showNoEndOfLine();? ? std::cout<<std::endl;}void showLine(const Line& line){? ? line.show();}int main(){? ? int num, i;? ? Point p(1, -2), q(2, -1), t;? ? t.show();? ? std::cin>>num;? ? Line line[num + 1];? ? for(i = 1; i <= num; i++)? ? {? ? ? ? line[i].readLine();? ? ? ? showLine(line[i]);? ? }? ? Line l1(p, q), l2(p,t), l3(q,t), l4(l1);? ? showLineCoordinate(l1);? ? showLinePoint(l2);? ? showLinePoint(l3.setLine(l1));? ? showLineCoordinate(l4.setLine(t,q));? ? line[0].setStart(t);? ? line[0].setEnd(q);}
查看完整描述

1 回答

?
Popper0912

TA貢獻5條經(jīng)驗 獲得超0個贊

代碼寫規(guī)范點,再來吧。。。

查看完整回答
反對 回復 2016-03-19
  • 1 回答
  • 0 關注
  • 1920 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號