请各位大神帮忙看一下,下面这段程序哪里出错了??谢谢!
#include<iostream>#include<cmath>#include<cassert>usingnamespacestd;classpoint{public...
#include<iostream>
#include<cmath>
#include<cassert>
using namespace std;
class point
{
public:
point();
point(int xx,int yy);
~point();
point(point& p2);
void move(int x=0,int y=0);
private:
int x,y;
};
point::point(){cout<<"point的默认构造函数"<<endl;}
point::point(int xx,int yy){x=xx;y=yy;cout<<"point的构造函数"<<endl;}
point::~point(){cout<<"point的析构函数"<<endl;}
point::point(point& p2){x=p2.x;y=p2.y;cout<<"复制构造函数"<<endl;}
void point::move(int x,int y){this->x=x;this->y=y;cout<<"x="<<x<<" "<<"y="<<y<<endl;}
class arraypoint
{
public:
arraypoint(int size){points=new point[size];cout<<"arraypoint的构造函数"<<endl;}
~arraypoint(){delete []points;cout<<"arraypoint的析构函数"<<endl;}
point element(int index){assert(index>=0 && index<size);return points[index];}
private:
int size;point* points;
};
int main()
{
int count;
cout<<"please enter the number of count"<<endl;
cin>>count;
arraypoint arraypoint1(count);
arraypoint1.element(0).move(3,4);
arraypoint1.element(1).move(4,5);
return 0;
system("pause");
} 展开
#include<cmath>
#include<cassert>
using namespace std;
class point
{
public:
point();
point(int xx,int yy);
~point();
point(point& p2);
void move(int x=0,int y=0);
private:
int x,y;
};
point::point(){cout<<"point的默认构造函数"<<endl;}
point::point(int xx,int yy){x=xx;y=yy;cout<<"point的构造函数"<<endl;}
point::~point(){cout<<"point的析构函数"<<endl;}
point::point(point& p2){x=p2.x;y=p2.y;cout<<"复制构造函数"<<endl;}
void point::move(int x,int y){this->x=x;this->y=y;cout<<"x="<<x<<" "<<"y="<<y<<endl;}
class arraypoint
{
public:
arraypoint(int size){points=new point[size];cout<<"arraypoint的构造函数"<<endl;}
~arraypoint(){delete []points;cout<<"arraypoint的析构函数"<<endl;}
point element(int index){assert(index>=0 && index<size);return points[index];}
private:
int size;point* points;
};
int main()
{
int count;
cout<<"please enter the number of count"<<endl;
cin>>count;
arraypoint arraypoint1(count);
arraypoint1.element(0).move(3,4);
arraypoint1.element(1).move(4,5);
return 0;
system("pause");
} 展开
2个回答
百事牛
2024-10-28 广告
2024-10-28 广告
作为深圳奥凯丰科技有限公司的一员,对于zip删除文件的处理,我们可以这样回答:要打开zip压缩包中删除的文件,实际上需要首先明确文件是否真正从压缩包中移除了。如果文件已从zip中删除,那么就无法直接打开,除非有备份。但如果是指解压后删除了某...
点击进入详情页
本回答由百事牛提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询