C++ – Error: Initializing Argument 1 of


I've looked around and seen quite a few of these, but none of them provided the solution for my problem. I'm getting this compilation error with the following code:


enter image description here


const int TOP_WORDS = 25;


void topWords(Hash t, string word, string topA[]); 

int main()
    Hash table1;
    string word = "example";

    string topWordsArr[TOP_WORDS];

    topWords(table1, word, topWordsArr);



void topWords(Hash t, string word, string topA[])
    int i = 0;
    int tempCount = t.itemCount(word);
    int tempCount2 = t.itemCount(topA[i]);

    while (tempCount > tempCount2 && i < TOP_WORDS) {
        tempCount2 = t.itemCount(topA[i]);

    if (i > 0)

All the other posts I've seen about this error involved an incorrect syntax with declaring/passing the string array parameter, but I've double and triple checked it all and I'm certain it's correct; though I've been wrong before..

Best Solution

Using my crystal ball:

  • you're passing the Hash by value
  • this requires the copy constructor,
  • you don't have one (or it's botched, private or explicit)

So, take the Hash by reference

void topWords(Hash const& t, std::string const& word, std::string* topA); 


  • string[] is not a type in C++
  • don't use using namespace std;
  • don't use raw arrays; use std::vector<std::string> (or std::array<std::string, N>)