I'm working on a C++ program for class, and my compiler is complaining about an "ambiguous" function call. I suspect that this is because there are several functions defined with different parameters.
How can I tell the compiler which one I want? Aside from a case-specific fix, is there a general rule, such as typecasting, which might solve these kinds of problems?
Edit:
In my case, I tried calling abs()
inside of a cout
statement, passing in two double
s.
cout << "Amount is:" << abs(amountOrdered-amountPaid);
Edit2:
I'm including these three headers:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
Edit3:
I've finished the program without this code, but in the interest of following through with this question, I've reproduced the problem. The verbatim error is:
Call to 'abs' is ambiguous.
The compiler offers three versions of abs
, each taking a different datatype as a parameter.
abs
", but you haven't shown what those messages are. – Gavrastd::enable_if_t<std::is_pointer<T>::value, ...
This was where behaviour needed to be different for pointers/nonpointers and the respective overloads were not being matched intuitively. – Bisector