Hello everyone.

I am begginer with Hashing algorithm. So I had for project to write a simple Console Phonebook that uses Open Adress Hashing with Linear Probes. I was working with templates. When I compile it I get Unsolved External errors (5 of them) and I have no clue how to fix it. I know in some cases unsolved externals can be solved with "inline" keyword in function header or "export" for which I get not suported message from my Visual C++ compiler. So I would ask someone who has more experience just to try to compile this. My source is Zipped. Thanks in advance...

you need to define them within the header file

template <class Type>
class openadd {

    protected:
        virtual int HashFunkcija(const long& item) const = 0;
        Type **Element;
        int TableSize;
        Type DefaultItem;
    public:
        openadd(int TableSize=100);
        openadd(Type DefaultItem, int TableSize = 100);
        ~openadd();
        bool Store(const Type& item)
        {
	        int index = HashFunkcija(item.GetPhone());
	        for(int probe =0; probe<TableSize; probe++) 
            {
		        if( Element[index]->GetPhone() == item.GetPhone() )
			        return false;
		        else if( Element[index]->GetPhone() == DefaultItem.GetPhone() )
                {
			        Element[index] = new Type(item);//treba konstruktor kopije
			        cout << "Korisnik uspijesno ubacen!";
		        }
		        else
			        index = (index+1)%TableSize;
	        }
        }

        bool Retrieve(const long& tel, Type& found)const//ovdje je prvi arg int jer ce se trazenje vrsiti po broju
        {
	        int index = HashFunkcija(tel);
	        for(int probe=0; probe<TableSize; probe++)
            {
		        if(Element[index]->GetPhone() == tel )
                {
			        found = *Element[index]; //dodjela objekata preko reference //skakljivo
			        return true;
		        }
		        else
			        index = (index+1)%TableSize;
            }
        }
		

};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.