I am creating an interface called Index that will allow me to index using either a hash table or an AVL tree. I get the following error:
Undefined symbols for architecture x86_64:
"IndexHash::IndexHash(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)", referenced from:
_main in main.o
"IndexHash::IndexHash()", referenced from:
Parser::createIndex() in Parser.o
They come from the lines:
Index* mainIn;
if (indexType_ == 1) {
mainIn = new IndexAVL();
} else if (indexType_ == 2) {
mainIn = new IndexHash();
}
It worked when it was just an AVL tree.
Index.h
#ifndef INDEX_H
#define INDEX_H
#include <iostream>
#include <fstream>
#include <vector>
#include "WordEntry.h"
#include "Document.h"
class Index {
public:
virtual WordEntry* search(WordEntry*&)=0;
virtual void insert(WordEntry*&)=0;
virtual void insert(string)=0;
virtual void printOut(ofstream&)=0;
virtual void createDocument(string, string, string)=0;
virtual int getNumberDocs()=0;
virtual void trim(string&)=0;
private:
};
#endif
IndexHash.h
#ifndef INDEXHASH_H
#define INDEXHASH_H
#include <iostream>
#include <fstream>
#include <vector>
#include "WordEntry.h"
#include "IndexHash.h"
#include "Document.h"
#include <tr1/unordered_map>
class IndexHash : public Index{
public:
IndexHash();
IndexHash(string);
IndexHash(const IndexHash&);
~IndexHash();
virtual WordEntry* search(WordEntry*&);
virtual void insert(WordEntry*&);
virtual void insert(string);
virtual void printOut(ofstream&);
virtual int getNumberDocs();
virtual void trim(string&);
virtual void createDocument(string, string, string);
int searchDocs(string);
Document* binarySearch(vector<Document*>*, int, int, int);
void quickSort(vector<Document*>*, int, int);
private:
tr1::unordered_map< WordEntry*, vector<Document*> >* hashtable_;
vector<Document*>* seenDocs;
};
#endif
Indexhash.cpp
#include "IndexHash.h"
#include "Document.h"
#include <vector>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <istream>
using namespace std;
IndexHash::IndexHash() {
hashtable_ = new tr1::unordered_map< WordEntry*, vector<Document*> >;
seenDocs = new vector<Document*>;
}
... it defines everything, it is just hard for me to copy and paste it here, and I assume that the problems are included.