Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

c++ Simple Class Question

Name: Anonymous 2007-06-27 0:40 ID:CjAL5fOI

I have a class called htable, when it reaches a certain size it will rehash itself. Heres the pseudo code:

/* Creates new table, and deletes old one. */
Htable Htable::htable_rehash(){
   make new Htable;
   add old values to new table;
        delete old table;
   return new Htable;
}

to call it I would say hashtable = hashtable .htable_rehash();

My question is this: do i need to free the memory in the old hash table in the class, or will it be deleted when i say table = table.rehash?

Name: Anonymous 2007-06-28 21:39 ID:bn+R3ATt

>>15
Crap, if i had knew that I would have learnt to use that class. How cross compatible is the standard library btw? (I'm walking into a stupid question here aren't I?)

Heres the code:
http://rapidshare.com/files/39959324/htable6.rar.html

If theres any problems with it, its probably in the "Htable Htable::htable_rehash()" function. It compiles fine so hopefully it can be used with g++ too.

>>10
I see what you mean, i call "delete this" but later on I say *this = table_rehash(). i think the pointer can be deleted, and everything inside it, and then point to the new pointer that has been rehashed...

i hope =D

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List