标签:turn com str void int iostream img c++ IV
1 //设计一个线段类 2 #include<iostream.h> 3 class Point{ 4 private: 5 int x; 6 int y; 7 public: 8 Point(){} 9 Point(int x,int y){ 10 this->x=x; 11 this->y=y; 12 } 13 14 Point(Point &c){ 15 x=c.x; 16 y=c.y; 17 } 18 19 ~Point(){ 20 } 21 22 int GetX() const{ 23 return this->x; 24 } 25 26 int GetY() const{ 27 return this->y; 28 } 29 }; 30 31 32 class Line{ 33 private: 34 Point a; 35 Point b; 36 public: 37 Line(){} 38 Line(Point &a,Point &b){ 39 this->a=a; 40 this->b=b; 41 } 42 ~Line(){ 43 } 44 45 void ShowA()const{ 46 cout<<"a point is:"<<a.GetX()<<","<<a.GetY()<<endl; 47 } 48 void ShowB(){ 49 cout<<"b point is:"<<b.GetX()<<","<<b.GetY()<<endl; 50 } 51 52 }; 53 54 int main(){ 55 Point a(1,1),b(2,2); 56 Line myLine(a,b); 57 myLine.ShowA(); 58 myLine.ShowB(); 59 return 0; 60 }
标签:turn com str void int iostream img c++ IV
原文地址:https://www.cnblogs.com/Tobi/p/9244892.html