I have a class Node declared in node.h
. The methods are defined in node.cc
. I have another class Tree declared in tree.h
, with its methods defined in tree.cc
.
The insertPoint
method in tree creates a Node* node
variable and calls the insertNode
method with node
as a parameter. The insertNode
in turn invokes various methods of the Node class such as addChild
, setLevel
, getMinDist
etc, for example: node->getMinDist(...)
, node->setLevel(...)
Full source is here : 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);
};
However when I try to compile this code, I get the following error. What am I doing wrong !?
Undefined symbols for architecture x86_64:
"Node::getMinDist(std::__1::vector >)", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
"Node::getChildren()", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
"Node::getDistance(Node*)", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
"Node::addChild(Node*)", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
"Node::getLevel()", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*,
std::__1::allocator >, int) in tree.o
"Node::getPoint()", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o
"Node::setLevel(int)", referenced from:
Tree::insertNode(Node*, std::__1::vector<Node*, std::__1::allocator<Node*> >, int) in tree.o