6-2-11

2728 ワード

 1 #include<iostream>
 2 
 3 using namespace std;
 4 
 5 class Point
 6 {
 7 public:
 8     Point(int x=0,int y=0):x(x),y(y){}
 9     int getX() const {return x;}
10     int getY() const {return y;}
11 private:
12     int x,y;
13 };
14 int main()
15 {
16     Point a(4,5);
17     Point *p1;p1=&a;
18     cout<<(*p1).getX()<<endl;
19     cout<<a.getX()<<endl;
20     return 0;
21 }