求解!!!!!!

w346581442 w346581442 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include<iostream>
using namespace std;

class Point
{
public:
Point()
{
X=Y=0;
cout<<"default constructor called."<<endl;
}
Point(int xx,int yy)
{
X=xx;Y=yy;
cout<<"construnctor called."<<endl;
}
~Point()
{
cout<<"destrctor called."<<endl;
}

int GetX(){return X;}
int GetY(){return Y;}
void Move(int x,int y)
{
X=x;
Y=y;
}
private:
int X,Y;
};

class ArrayOfPoints
{
public:
ArrayOfPoints(int n)
{
numberOfPoints=n;
points=new Point[n];
}
~ArrayOfPoints()
{
cout<<"deleting "<<endl;
numberOfPoints=0;
delete [] points;
}
Point & Element(int n)//这句又是什么意思
{
return points[n];
}

private:
Point *points;
int numberOfPoints;
};

void main()
{
int number;
cout<<"please enter the number of points:";
cin>>number;
ArrayOfPoints points(number);//这句什么意思
points.Element(0).Move(5,10);
points.Element(1).Move(15,20);
}
...全文
评论 3
收藏 已收藏
分享
返回顶部
w346581442
C++ 语言 65,214 成员 250,514 内容