gives me error on 3rd coded line in search().

#ifndef MY_HT_CHAIN_H
#define MY_HT_CHAIN_H
#include <iostream>
#include <vector>
#include <list>

using namespace std;

class my_ht_chain
{
public:
	//constructor which creates a table of a certain size 
	my_ht_chain(int initTableSize);

	//destructor
	~my_ht_chain();

	//insert a value based on key
	void insert(int key);

	//search for a value based on key
	bool search(int key);

	//delete an item in the list
	void remove(int key);

	//prints out all items stored in hash table
	void show_ht_structure() const;

private: 
	//number of vectors to store in array
	int tablesize;

	//table to store key 
	vector<list<int>>* dataTable;

	//returns a int which corresponds to position in array
	int hashfunction(int key);
};



bool my_ht_chain::search(int key)
{
	list<int>::iterator list1;
	vector<list<int>>::iterator vector1;
	//1. find the array index
	vector1=dataTable->at(hashfunction(key));
	//2. search the list at that array index found above till key matches if not return false
	
}

int my_ht_chain::hashfunction(int key)
{
	return (key%tablesize);
}

gives me error on 3rd coded line in search().

#ifndef MY_HT_CHAIN_H
#define MY_HT_CHAIN_H
#include <iostream>
#include <vector>
#include <list>

using namespace std;

class my_ht_chain
{
public:
	//constructor which creates a table of a certain size 
	my_ht_chain(int initTableSize);

	//destructor
	~my_ht_chain();

	//insert a value based on key
	void insert(int key);

	//search for a value based on key
	bool search(int key);

	//delete an item in the list
	void remove(int key);

	//prints out all items stored in hash table
	void show_ht_structure() const;

private: 
	//number of vectors to store in array
	int tablesize;

	//table to store key 
	vector<list<int>>* dataTable;

	//returns a int which corresponds to position in array
	int hashfunction(int key);
};



bool my_ht_chain::search(int key)
{
	list<int>::iterator list1;
	vector<list<int>>::iterator vector1;
	//1. find the array index
	vector1=dataTable->at(hashfunction(key));
	//2. search the list at that array index found above till key matches if not return false
	
}

int my_ht_chain::hashfunction(int key)
{
	return (key%tablesize);
}

better you can use map

i got it to work so its all good.

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.