lundi 4 septembre 2017

ambiguating new declaration of 'unsigned char*

I am writing a c++ application, and it's been a while since I have used c++. I am having an issue with this function:

unsigned char* BuildArray(string integerString)
{

    int numIndexs = integerString.length() + 1;

    unsigned char charArray[numIndexs];

    /*
     * Loops through and stores all of the characters in the string into a unsigned char array
     */
    for(int i = 0; i < numIndexs; i++)
    {
         if(i == 0)
         {
             charArray[0] = 0;
         }
         else
         {
             charArray[i] = integerString.at(i-1) - 48;
         }
    }

    outputArray(charArray);
    unsigned char* returnValue = &charArray[0];

    return returnValue;

}

It gives me the error: ambiguating new declaration of 'unsigned char* BuildArray(std::string). I checked around and the only other post I could find was this one: "ambiguating new declaration" error for a templated method in a templated class

However, the answer wasn't clear enough for me. So I'm not sure how to fix this.

Aucun commentaire:

Enregistrer un commentaire