懂C++的进,求高手,在线等,

来源:百度知道 编辑:UC知道 时间:2024/05/05 05:54:14
//main.cpp
#include<iostream>
#include"point.h"
using namespace::std;
void main()
{
point p,p1(5,8);
cout<<p.getx<<' '<<p.gety;
cout<<endl;
cout<<p1.getx<<' '<<p1.gety;
cout<<endl;
p.move(2,2);
p1.move(2,2);
cout<<"new point:";
cout<<p.getx<<' '<<p.gety;
cout<<endl;
cout<<p1.getx<<' '<<p1.gety;
cout<<endl;
}

//point.h
#include<iostream>
using namespace::std;
class point
{
public:
point();
point(int xx,int yy);
void move(int xx,int yy);
int getx();
int gety();
private:
int x,y;
};

//point
#include<iostream>
#include"point.h"
using namespace std;
point::point()
{x

#include<iostream>
using namespace std;
class point
{
public:
point();
point(int xx,int yy);
void move(int xx,int yy);
int getx();
int gety();
private:
int x,y;
};
point::point()
{x=0;y=0;}
point::point(int xx,int yy)
{x=xx;y=yy;}
int point::getx()
{return x;}
int point::gety()
{return y;}
void point::move(int xx, int yy)
{x+=xx;
y+=yy;
}
void main()
{
point p,p1(5,8);
cout<<p.getx<<' '<<p.gety();
cout<<endl;
cout<<p1.getx<<' '<<p1.gety();
cout<<endl;
p.move(2,2);
p1.move(2,2);
cout<<"new point:";
cout<<p.getx<<' '<<p.gety();
cout<<endl;
cout<<p1.getx<<' '<<p1.gety();
cout<<endl;
}

cout<<