Implement a C++ program to overload the function named as sum, to perform sum of two integer and perform sum of float two number respectively.
#include <iostream>
int sum(int a, int b)
{
return a + b;
}
float sum(float a, float b)
{
return a + b;
}
int main()
{
std::cout << "Sum of ints: " << sum(1, 2) << "\n";
std::cout << "Sum of floats: " << sum(1.0f, 2.0f) << "\n";
return 0;
}
Comments
Leave a comment