我的代码:
class Point3D{
protected:
float x;
float y;
float z;
public:
Point3D(){x=0; y=0; z=0;}
Point3D(const Point3D & point){x = point.x; y = point.y; z = point.z;}
Point3D(float _x,float _y,float _z){x = _x; y = _y; z = _z;}
}
class Vector3D{
protected:
Point3D start;
Point3D end;
public:
...
Point3D getSizes(){
return Point3D(end-start);
}
}
我想创建和三维点操作+,将采取一个向量:
Point3D & operator+(const Vector3D &vector){
Point3D temp;
temp.x = x + vector.getSizes().x;
temp.y = y + vector.getSizes().y;
temp.z = z + vector.getSizes().z;
return temp;
}
但是,当我把该操作iside三维点类的声明,我有错误,因为我没有做的Vector3D声明在这里。 我不能三维点之前移动的Vector3D声明,因为它使用三维点。