Generic Programming Doubt

Hey, In the video why it showed the error when 1.2 was passed as a key without being stored in a key variable of data type float. Please explain this?

hello @Sakshi2004

pls mention the timestamp where u have doubt

compiler is treating 1.2 as double instead of float .
hence due to type mismatch it is showing compile error

But we can use the float data type in C++, so why compiler dosen’t differentiate between float and double or is it treated as same? If so, then what is the difference between the float and double in general.

by default compiler treats decimal numbers as double.
if u want to make them float then u have to declare it explicitly

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.