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;
}Metadata;

Can anyone point me in the correct direction?

Thanks

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.