c++程序.求讲解下!

来源:百度知道 编辑:UC知道 时间:2024/06/16 00:49:41
#incldue<iostream.h>
class Point
{
private:
int x,y;
public;
void SetPoint(int a,int b)
{
x=a;
y=b;
}
void SetPoint(int a=0);
int GetX()
{
retruen x;
}
int Get Y()
}
void ShowPoint() //这里
{ 有什么用?
cout<<"("<<","<<y<<")"<<endl;
}
};
void Point::SetPoint(int a) //这个是构造函数吗?
{
x=y=a;
}
void main()
{
Point p1,p2mp3; //以下的输出都起什么作用?
p1.SetPoint();
p2.SetPoint(5,8);
p3.SetPoint(20);
cout<<"p1(:"<<p1.GeX()<<","<<p1.GeY()<<')'<<endl;
cout<<"p2";
p2.Showpoint();
cout<<"p3:;
p3.ShowPoint();
}

#incldue<iostream.h>
class Point
{
private:
int x,y;
public;
void SetPoint(int a,int b)
{
x=a;
y=b;
}
void SetPoint(int a=0);
int GetX()
{
retruen x;
}
int Get Y()
}
void ShowPoint() //这里
{ 有什么用?
cout<<"("<<","<<y<<")"<<endl; //应该是写错了吧,他的意思是(x,y)
}
};
void Point::SetPoint(int a) //这个是构造函数吗? //不是构造函数,这里是一个重载的函数
{
x=y=a;
}
void main()
{
Point p1,p2mp3; //以下的输出都起什么作用?
p1.SetPoint(); //创建三个对象,然后分别输出这三个对象的点坐标。
p2.SetPoint(5,8);
p3.SetPoint(20);
cout<<"p1(:"<<p1.GeX()<<","<<p1.GeY()<<')'<<endl;
cout<<"p2";
p2.Showpoint();
cout<<"p3:;
p3.ShowPoint();
}