编译时
void ambig( signed long) { }
void ambig(unsigned long) { }
int main(void) { ambig(-1); return 0; }
Run Code Online (Sandbox Code Playgroud)
我明白了
error C2668: 'ambig' : ambiguous call to overloaded function
could be 'void ambig(unsigned long)'
or 'void ambig(long)'
while trying to match the argument list '(int)'
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过说-1L而不是-1,但为什么/如何在一开始就被认为是模棱两可的来"解决"它?