#include <iostream>
using namespace std;
class Point{ //定义类Point
double x,y; //有两个变量
public:
Point(double x0,double y0) :x(x0),y(y0){};
Point():x(0),y(0){};
void Set(double a, double b)
{
x=a;
y=b;
}
double GetX(){//返回x和y的值
return x;
}
double GetY(){
return y;
}
};
void Show(Point[],a)
{
for(int i=0;i<5;i++)
cout<<"("<<a[i].GetX()<<","<<a[i].GetY()<<")";
}
///////////////////////////////////////////////////////
int main()
{
Point a[5]={Point(0,0),Point(1,1),Point(2,2),Point(3,3),Point(4,4)};
Point*p=a;
p->Set(5,9);
a[3].Set(6,8);
for (int i=0; i<5; i++){
Show(p++);
}
return 0;
}
什么意思
这是只是单纯的定义数组a吗
如果是的话在using namespace std;的下一行写:a[105];
数组里的数自己填自己需要的
这样应该不会报错了
如果可以,点一下采纳
谢谢