I am trying to define a structure for a hash table. I am making a constructor in my structure but I cannot get it to work with anything except chars. Strings always get me confused as how to manipulate them here. I have a string as my key and a custom Record class as my value. If I use chars as either one it works but does not work with my custom values.

typedef struct Metadata
    struct Metadata(string *key, Record* value)
        this->key == key;
        this->value = value;
        next = NULL;
    string key[SIZE_KEY];
    Record value[SIZE_VALUE];
    struct Metadata * next;

Can anyone point me in the correct direction?


9 Years
Discussion Span
Last Post by WaltP

string key[SIZE_KEY]; states "define an array of SIZE_KEY strings". What it seems you want is a single string of SIZE_KEY characters, which would be char key[SIZE_KEY]; A string is dynamic and changes as you add characters to it, so there is no need to attempt to define the size.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.