c++linker-errorsheader-filesforward-declarationfunction-signature

C++ more than one instance of overloaded function matches the argument list when creating a header file


Within my main file of my program I have the following declarations

int main()
{
    Customer c;
    Part p;
    Builder b;
    auto partsVec =  readpartFile();
    auto customerVec = readcustomerFile();
    auto builderVec = readbuilderFile();

    fexists("Parts.txt");
    complexity(c, partsVec);
    robotComplexity(partsVec,customerVec);
    writeFile(buildAttempt(b, complexity(c, partsVec), variability(customerVec, builderVec)));
}

My header file consists of the following

vector<Part> readpartFile();

vector<Customer> readcustomerFile();

vector<Builder> readbuilderFile();

float complexity(const Customer& c, const std::vector<Part>& parts);

void robotComplexity(vector<Part> vecB, vector<Customer> vecC);

double variability(const vector<Customer>& customerList, const vector<Builder>& builderList);

vector<double> buildAttempt(Builder b, double variaiblity, double complexityRobot);

void writeFile(vector<double> build);

All functions link up except for robotComplexity. My declaration of this function in main creates the following error.

more than one instance of overloaded function "robotComplexity" matches the argument list: -- function "robotComplexity(const std::vector> &parts, const std::vector> &customers)" -- function "robotComplexity(std::vector> vecB, std::vector> vecC)" -- argument types are: (std::vector>, std::vector>)

im not sure why im getting this error or how to resolve it


Solution

  • You have a mismatch between declaration in header and definition (which also serves as declaration):

    Whereas parameter names can mismatch, types shouldn't, else, you create another overload.