![]() |
| ||
| Hash Table display problem 1 Attachment(s) I wrote a hash table that takes a char as a key and for a test I am using a string for my value. It uses a linked list. But I am having a problem displaying the value. I have a function that displays the key correctly but the value is displayed as garbage. I am prety sure it is this one method that is causing it to display incorrectly but it complies and runs fine, i am just not sure why this does not work. Here is the method I think is not working and I am attaching the entire sample program as a txt file if someonecan take a look. I a little stuck on this. bool Hashtable::get(char *key, string value) Here is my Display Function and it calls this function so I am assuming that for some reason the data is not bein copied correctly. void displayAll(Hashtable *hashtable)Thanks |
| ||
| Re: Hash Table display problem value is an array. When you pass it as the second argument to get, it acts as the initializer for the std::string parameter. You've lost your reference, and any changes to the parameter will not be reflected back in displayAll. Change value to a string and pass it by reference to get. |
| ||
| Re: Hash Table display problem Ahh thank you. I did that and it worked perfectly. |
| All times are GMT -4. The time now is 6:08 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC