samedi 9 décembre 2017

Abstract Data Type Pass as a parameter

Hey so im trying to pass a hash table as a parameter in c++, when i call the function that i am trying to run i get an error message that i do not understand.

So this is the function:

string getRandomKey(int tableNumber, int tableSize, HashTable<string>* table, int random){
    random *= rand() % tableSize + 1;
    string randKey = to_string(tableNumber) + to_string(random);

    if((table->find(randKey)) == true){
        cout << "Key: " << randKey << " found ";
        return randKey;
    }
    return "";  
}

This is by no means the final version im just trying to test it. Some context is that i have a couple of hash tables, and a separate integer variable that has the number of elements that i have predetermined. The keys are set to be one of the random numbers.

Anyway so here is where i call the function:

table1->print(getRandomkey(1, sizes[2], table1*, 1));

And i get this error:

error: expected expression
    table1->print(getRandomKey(1, sizes[2], table11*, 1));
                                                ^
1 error generated.

So, im not sure what i need to change or if i messed something up somewhere else. Thanks for any help you guys can give!




Aucun commentaire:

Enregistrer un commentaire