Hello all - always hate to make my first post but after more than an hour of looking I can't figure out what I have done wrong...
I'm writing a simple program to store a tree of strings, and am getting the following error after compiling with g++.
Here is my Ontology.cpp file:Code:Undefined symbols: "Ontology::InsertTerm(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, ItemType*)", referenced from: Ontology::InsertTerm(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in ccDEky9Q.o ld: symbol(s) not found collect2: ld returned 1 exit status
Inside an included header in Ontology.h isCode:// Johan Henkens and Kevin Wang for CS24 Lab06 Winter 2010 UCSB #include "Ontology.h" Ontology::Ontology(ItemType* type){ head.push_back(type); } //Observers bool Ontology::IsEmptyOnt(){ return head.size()==0; } // "" signifies no parent bool Ontology::InsertTerm(string parent, string newNode){ if(parent.compare("")==0){ ItemType* tempRef = new ItemType(); tempRef->Initialize(newNode, NULL); head.push_back(tempRef); return true; } for(int i = 0; i < head.size();i++){ if(head[i]->GetData()==parent){ for(int o = 0; o<head[i]->getChildrenSize();o++){ if(head[i]->getChild(o)->GetData().compare(newNode)==0) return true; } ItemType* temp = new ItemType(); temp->Initialize(newNode,head[i]); head[i]->pushToChildren(temp); return true; } } for(int i = 0; i < head.size();i++){ if(InsertTerm(parent, newNode, head[i])) return true; } return false; } bool InsertTerm(string parent, string newNode, ItemType* root){ if(root->GetData()==parent){ for(int i = 0; i<root->getChildrenSize();i++){ if(root->getChild(i)->GetData().compare(newNode)) return true; } ItemType* temp = new ItemType(); temp->Initialize(newNode,root); root->pushToChildren(temp); return true; } for(int i = 0; i < root->getChildrenSize();i++){ if(InsertTerm(parent, newNode, root->getChild(i))) return true; } return false; }
so I doubt it is that I haven't included the right libraries.Code:#include <iostream> #include <string> #include <vector> using namespace std;
I am completely lost as to where I am to go from here. Any advice would be wonderful




Reply With Quote