为什么下面的代码总是打印“type is double”? (我在 StackOverflow 上看到过这段代码)
#include <iostream>
void show_type(...) {
std::cout << "type is not double\n";
}
void show_type(double value) {
std::cout << "type is double\n";
}
int main() {
int x = 10;
double y = 10.3;
show_type(x);
show_type(10);
show_type(10.3);
show_type(y);
return 0;
}
最佳答案
http://en.cppreference.com/w/cpp/language/overload_resolution说:
A standard conversion sequence is always better than a user-defined conversion sequence or an ellipsis conversion sequence.
关于c++ - 为什么调用了不合适的重载函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33584489/