'No instance of overloaded function matches argument list.

I'm working on a project for class, but keep getting the error: no instance of overloaded function matches argument list. It is referencing my String classes. What I am trying to do is create a Copy, Concat and Count functions with out using the string class. Any help would be greatly appreciated.

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

using namespace std;

class String
{
private:
char str[100]; 
char cpy[100];
public:

static const char NULLCHAR = '\0';

String()
{
    str[0] = NULLCHAR;
    cpy[0] = NULLCHAR;
}

String(char* orig, char* cpy)
{
    Copy(orig, cpy);
}

void Display()
{
    cout << str << endl;
}

void Copy(char* orig, char* dest)
{

    while (*orig != '\0') {
        *dest++ = *orig++;
    }
    *dest = '\0';



}

void Copy(String& orig, String& dest) 
{
    Copy(orig.str, dest.cpy);
}

void Concat(char* orig, char* cpy)
{
    while (*orig)
        orig++;

    while (*cpy)
    {
        *orig = *cpy;
        cpy++;
        orig++;
    }
    *orig = '\0';

}

void Concat(String& orig, String& cpy)
{
    Concat(orig.str, cpy.cpy);
}

int Length(char* orig)
{
    int c = 0;
    while (*orig != '\0')
    {
        c++;
        *orig++;
    }
    printf("Length of string is=%d\n", c);
    return(c);

}
};

int main()
{
String s;

s.Copy("Hello");
s.Display();
s.Concat(" there");
s.Display();

String s1 = "Howdy";
String s2 = " there";
String s3;
String s4("This String built by constructor");
s3.Copy(s1);
s3.Display();
s3.Concat(s2);
s3.Display();
s4.Display();


system("pause");
return 0;
}
c++


Solution 1:[1]

It looks like your Copy and Concat functions each take two parameters, yet you pass them both a single parameter. If you want to copy them into a String object, your code should look more like:

String Copy(char* orig)
{
    // Same copy logic you have, 
    // except copy into "*this"
}

Solution 2:[2]

As the error message says, There is no version of the constructor for your String class that takes a single parameter. You have a default constructor and one that takes two parameters.

You need to define one which takes a single parameter and initializes the str

Solution 3:[3]

String s4("This String built by constructor"); this statement needs construction function

String(char *);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dagrooms
Solution 2 Aakash Arayambeth
Solution 3 shiningstarpxx