How do I fix an “ambiguous” function call?

后端 未结 4 1122
礼貌的吻别
礼貌的吻别 2021-02-18 14:59

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

4条回答
  •  独厮守ぢ
    2021-02-18 15:32

    What's happened is that you've included (indirectly, since it's included by iostream) along with using namespace std;. This header declares two functions in std with the name abs(). One takes and returns long long, and the other returns long. Plus, there's the one in the global namespace (that returns int) that comes from .

    To fix: well, the abs() that takes double is in , and that will actually give you the answer you want!

提交回复
热议问题