Float and double problem in overlaoding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Float and double problem in overlaoding

#include <iostream> using namespace std; void sum(double a){ cout<< "it was a float"; } void sum(int u){ cout<< "it was a int"; } int main() { sum(2); sum(2.1); return 0; } In this code when I Interchange the 'double a' to 'float a' in the first function it raises an error but according to lessons it should work I don't understand whats happening I guess float and double should behave similarly (Try running the code in c++ by changing the float to double and vice versa to get an idea of what I am talking)

2nd Apr 2020, 4:33 PM
Sajal Chuttani
Sajal Chuttani - avatar
1 Answer
- 1
Then what's the difference between float and double According to your explanation ~swim~ float is more similar to int tham it is to double. Is it so??
2nd Apr 2020, 5:05 PM
Sajal Chuttani
Sajal Chuttani - avatar