找不到此问题的明确解决方案。
我有两个班级Point
和Vector
. Vector
是我想使用类的对象的类Point
方法之一的子级。我这样做:Point
Vector
class Point
{
double x, y, z;
public:
// constructor from 3 values
Point(double x, double y, double z)
: x(x), y(y), z(z)
{}
// method move point
Point move(Vector vect, double dist)
{
Vector vectU = vect.unit();
return sum(vectU.multiplyScalar(dist));
}
};
class Vector: public Point
{
double x, y, z;
public:
// constructor from 3 values
Vector(double x, double y, double z)
: Point(x, y, z), x(x), y(y), z(z)
{}
// create unit vector
Vector unit()
{
double len = length();
return Vector(x / len, y / len, z / len);
}
};
当我编译它时,它给了我一个错误Point move(Vector vect, double dist)
"Vector" has not been declared
。我找不到任何有用的答案来解决这个错误。我该如何做这个初始化?