0
#include "iostream"

void func(int Y)
{
    std::cout << Y;
}


void func(float X)
{
    std::cout << X;
}

int main()
{
    func(5);

    func(5.0);
}

When I switch the argument type from float to double this works I get no errors. is the compiler treating float as int?

1 Answers1

3

5.0 is a double not a float, so both functions are an equal match.

Use 5.0f for float.

Hatted Rooster
  • 35,759
  • 6
  • 62
  • 122