0
Does someone know why this code fit with double but return errors with float?
2 odpowiedzi
+ 3
because without specifying numeric literal operator, literals with a dot default to double... so compiler doesn't know if it may cast value to float or to int (ambiguous) ^^
with float, you must specify your literal float:
add(1.2f, 6.5f);
+ 2
Because for whatever reason cpp see's those floats as doubles regardless of how you define the function. Look here, i changed the function to float, then forced the two float numbers to be read as a float by postfixing an 'f' on the end of the number for 'float'
https://code.sololearn.com/cLfJKBLh3FQ2/?ref=app