I have a lookup function in my hash table class which returns a pointer to the hash table bucket if the element x is found. Is this a safe way to declare a pointer and return it?
1 2 3 4 5 6 7 8 9 10 11 12
int * hashtable::lookup(double x) {
int bucket = hash(x); //hash(x) returns an int.
int *BukPtr = newint;
BukPtr = &bucket;
linkedlist *LL = &hash_table[bucket];
if(LL->search(x)) {
return BukPtr;
}
elsereturn 0;
}