#include<iostream>
using namespace std;
class Point {
public:
Point() : _x(0), _y(0) {};
Point(int x, int y) : _x(x), _y(y) {};
~Point() {};
void setX(int x){ _x = x; }
void setY(int y){ _y = y; }
int getX() const { return _x; }
int getY() const { return _y; }
private:
int _x, _y;
};
int main()
{
Point *ptr=new Point[5];
for(int i=0;i<5;i++)
{
int xx,yy;
cin>>xx>>yy;
ptr[i].setX(xx),ptr[i].setY(yy);
cout<<ptr[i].getX()<<'\t'<<ptr[i].getY()<<endl;;
}
delete []ptr;
return 0;
}
对象数组
最新推荐文章于 2022-03-20 11:53:33 发布