Why does passing the literal 3 choose the int overload instead of the short overload?

Viewed 3810

How does C++ handle function overloading in this case?

#include <iostream>

void func(int x)
{
   std::cout << "integer";
}

void func(short x)
{
   std::cout << "short";
}

int main(void)
{
   func(3);
}

Output: integer

Why is that?

5 Answers
Related