#include
#include
using namespace std;
class Point
{
private:
float x,y;
public:
Point(){}
Point(float a,float b):x(a),y(b){}
Point(Point& a);
float Distance(Point b);
};
Point::Point(Point& a)
{
x=a.x;
y=a.y;
}
float Point::Distance(Point b)
{
return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y));
}
class Line:public Point
{
private:
Point a,b;
public:
Line(float x1,float y1,float x2,float y2):a(x1,y1),b(x2,y2){}
float Display();
};
float Line::Display()//这个地方不知道你要输出的是什么,但从你的源程序中知道要返回一个值,所以,我返回了线段的距离
{
return a.Distance(b);
}
int main()
{
Point a;
Point b(7.8,9.8),c(34.5,67.8);
a=c;
cout<<"两点之间距离是:"<
cout<
}
Class Point
{
private:
float x,y;
public:
Point(float x, float y)
{
this.x=x;
this.y=y;
}
float Distance(Point b)
{
return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y));
}
}
Clase Line:public Point
{
private:
Point a;
Point b;
public:
Line(float x1,float y1,float x2,float y2)
{
a.x=x1;a.y=y1;
b.x=x2;b.y=y2;
}
void Display(void)
{
cout<<"A("<
}
chass point
{
point(int a,int b)
{
x=a;
y=b;
}
private:
point *p;
int x,y;
public:
int getx()
{
return x;
}
int getx()
{
return y;
}
int Distance(point *q)
{
p=q;
return squre((x-q->getx())*(x-q->getx())+(y-q->gety())*(y-q->gety()));
}
}
chass line public:point
{
line(int a,int b,int c,int d)
{
x=a,y=b,x1=c,y1=d;
}
private:
int x1,x2;
public:
int Distplay()
{
return squre((x-x1)*(x-x1)+(y-y1)*(y-y1));
}
}