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-29 22:55 ID:2Dq2ukvu

>>24
yeah, a lot of the code is actually copied from a C hash table I wrote.

You say that my program is vulnerable to memory leaks, but where? I used free() to clean up the malloced memory, and delete do get rid of the classes =D

I try to avoid the vector class, I don't really understand it. I'm not defending my noob C++ methods, I'm just new to it. any good tutorials explaining it?

I feel safer with C techniques as I'm migrating to C++. but hey, it works!

but 99% of people who program C++ hate that cin<<"text here" crap, it just looks ugly. like fprintf()

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