【发布时间】:2011-03-17 22:11:09
【问题描述】:
#include <iostream>
#include <math.h>
using namespace std;
class Point{
public:
Point(int xx, int yy);
~Point();
int getX();
int getY();
void setX(int xx){ x = xx; }
void setY(int yy){ y = yy;}
private:
int x;
int y;
};
Point::Point(int xx, int yy)
{
x = xx;
y = yy;
}
Point::~Point()
{
}
int Point::getX()
{
return x;
}
int Point::getY()
{
return y;
}
class Line
{
public:
Line(Point one, Point two);
~Line();
float length();
private:
Point a;
Point b;
};
Line::Line(Point one, Point two)
{
a.setX = one.getX;
a.setY = one.getY;
b.setX = two.getX;
b.setY = two.getY;
}
float Line::length()
{
int x1,y1,x2,y2;
float linelength;
x1 = a.getX;
y1 = a.getY;
x2 = b.getX;
y2 = b.getY;
linelength = ((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1));
linelength = sqrtf(linelength);
return linelength;
}
int main()
{
Point mine(1,1);
Point yours(2,2);
Line ours(mine, yours);
cout << Line.linelength();
return 0;
}
【问题讨论】:
-
请重新格式化代码。选择所有内容并按“代码”按钮。另外,请解释一下您在做什么以及遇到什么错误。
-
有人请添加信息问题实际上是关于什么的?
-
你认为它有什么问题?你甚至尝试编译它吗?发生了什么?为什么你认为这是错误的?你的问题是缺乏的。 -1
-
大概是关于编译错误。