C++学习(7)

 1 //内部类的学习
 2 #include<iostream.h>
 3 class Line{
 4     class Point{
 5         public:
 6             int x;
 7             int y;
 8             Point(int x=0,int y=0){
 9                 this->x=x;
10                 this->y=y;
11             }
12             ~Point(){}
13     };
14     private:
15         Point a;
16         Point b;
17     public:
18         Line(int x1,int y1,int x2,int y2):a(x1,y1),b(x2,y2){}
19         ~Line(){};
20         void ShowA()const{
21             cout<<"a point is:("<<a.x<<","<<a.y<<")"<<endl;
22         }
23         void ShowB()const{
24             cout<<"b point is:("<<b.x<<","<<b.y<<")"<<endl;
25         }
26 };
27 
28 int main(){
29     Line myLine(0,10,50,50);
30     myLine.ShowA();
31     myLine.ShowB();
32     return 0;
33 }

猜你喜欢

转载自www.cnblogs.com/Tobi/p/9244943.html
今日推荐