How function overloading works with double and float
问题 I have two overloaded methods double Sum(double n1, double n2) { return n1 + n2; } float Sum(float n1, float n2) { return n1 + n2; } When i call Sum(5.5, 5.5), the method with double return type gets called. My question is why the method with double return type is called, why not method with float return type. How the compiler is deciding that which method should be called. 回答1: Because, floating-point literals such as 5.5 have the type double in C++ as default. That's why, when you pass a