我在node.h
中声明了一个类Node。这些方法在node.cc
中定义。我在tree.h
中声明了另一个类Tree,其方法在tree.cc
中定义。
树中的insertPoint
方法创建了一个Node* node
变量,并以insertNode
方式调用node
方法作为参数。 insertNode
依次调用Node类的各种方法,例如addChild
,setLevel
,getMinDist
等,例如:node->getMinDist(...)
,node->setLevel(...)
完整来源位于:https://github.com/apoorvreddy/covertree
class Node {
private:
Point *point;
int level;
std::vector<Node*> children;
public:
Node(Point *p) {
point = p;
}
Node(Point* p, int l) {
point = p;
level = l;
}
~Node();
Point* getPoint();
std::vector<Node*> getChildren();
int getLevel();
void setLevel(int l);
void addChild(Node *n);
double getDistance(Node* node);
double getMinDist(std::vector<Node*> nodeList);
};
class Tree {
private:
float base;
int maxLevel;
int minLevel;
Node* root;
std::vector<Point> pointSet;
bool insertNode(Node* node, std::vector<Node*> coverset_qi, int level);
public:
Tree();
void insertPoint(Point& point);
};
但是,当我尝试编译此代码时,出现以下错误。我做错了什么!?
架构x86_64的未定义符号:
“Node :: getMinDist(std :: __ 1 :: vector&gt;)”,引自:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
“Node :: getChildren()”,引自:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
“Node :: getDistance(Node *)”,引自:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
“Node :: addChild(Node *)”,引自:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
“Node :: getLevel()”,引自:
tree.o中的Tree::insertNode(Node*, std::__1::vector<Node*,
std :: __ 1 :: allocator&gt;,int)
“Node :: getPoint()”,引自:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
“Node :: setLevel(int)”,引自:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o