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

David Ling

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

Jarod42

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

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

c++ template - More than one instance of overloaded function matches the argument list

More than one instance of overloaded function matches the argument list and I can't find where the error happens

c++ more than one instance of overloaded function matches argument type

C++ No instance of overloaded function matches the argument list when calling std::replace()

No instance of overloaded function matches the argument list

Error passing Eigen matrix to a function in C++: "no instance of overloaded function matches the argument list"

How to fix "no instance of overloaded function "getline" matches the argument list" when using getline with an int

Error No instance of overloaded function "getline" matches the argument list

no instance of overloaded function "std::make_unique" matches the argument list

c++ struct in map as value - error "no instance of overloaded function matches the argument list"

C++ and SFML, no instance of the overloaded function "sf::RenderWindow.draw()" matches the argument list

no instance of overloaded function "std::make_unique" matches the argument list, but works with unique_ptr constructor

No instance of overloaded function winrt::Windows::UI::Xaml::Controls::Primitives::SelectorItem::Content matches the argument list

C++ no instance of function template matches the argument list

No instance of overloaded function "std::vector<_Ty, _Alloc>::erase [with _Ty=Enemy *, _Alloc=std::allocator<Enemy *>]" matches the argument list

Can I create an instance by reflection and specify the overloaded "params" constructor when there is only one argument c#?

Creating a List - Creating one more level of list than wanted

getline() not taking delimiter argument (ERROR: no instane of overloaded function "getline" matches argument list

Why am I having trouble with getline()? "No instance of overloaded functions matches the argument list" and "data is ambiguous"

c++ getline() error, no instance of overload function "getline" matches the argument list

How can I fix a "no instance of function template 'Defer' matches the argument list" error in C++?

How to pass more than one element of a list to argument in a custom function - Python

No instance of function template "ExtractSpherical_kernel" matches the argument list

no instance of function template matches the argument list (trying to print array)

CUDA template error: no instance of function template matches the argument list

No instance of function template "std::make_pair" matches the argument list

no instance of function template matches the argument list i dont know why

OnComponentBeginOverlap.AddDynamic says no instance of the function template matches the argument list?

What is the precedence when more than one method overload matches?