eb22.c

来自「gcc3.2.1源代码」· C语言 代码 · 共 27 行

C
27
字号
// Ambiguous conversion, three candidates:// builtin == (int, int), and the two user-defined operators// Each one requires a user-defined ICS where another uses builtin conversions,// so none is the best viable function.class MyInt{public:        MyInt(int = 0) {}        operator int() const {return 2;}};bool operator==(const MyInt& a, const int& b){                                               // ERROR - candidate        return (int)a == b;}bool operator==(const MyInt& a, const MyInt& b){                                               // ERROR - candidate        return (int)a == (int)b;}bool f(){  return 3 == MyInt();                          // ERROR - ambiguous}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?