请各位大神帮忙看一下,下面这段程序哪里出错了??谢谢!
#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-08-28 广告
2024-08-28 广告
在当今竞争激烈的商业环境中,企业需要不断提高自身的竞争力,以保持市场份额和增加利润。通过人效提升,企业可以更有效地利用有限的资源,提高生产力和效益,从而实现盈利目标。中智咨询提供全方位的组织人效评价与诊断、人效提升方案等数据和管理咨询服务。...
点击进入详情页
本回答由中智咨询提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询