Answer to Question #325270 in C++ for Sheena

Question #325270

Create a program that will overload a function four (4) times. The function takes a single parameter but each parameter is different in each function.


1
Expert's answer
2022-04-07T17:39:49-0400
#include <iostream>
using namespace std;

int sum(int a, int b);
int sum(int a);
double sum(int a, double b);
double sum(double a, double b);

int main()
{
	cout << sum(4, 5) << endl;
	cout << sum(5) << endl;
	cout << sum(5, 7.65) << endl;
	cout << sum(8.85, 9.61) << endl;

	return 0;
}

int sum(int a, int b)
{
	return a + b;
}

int sum(int a)
{
	return a + a;
}

double sum(int a, double b)
{
	return a + b;
}

double sum(double a, double b)
{
	return a + b;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS