Write an overloaded function called product The first functi
Write an overloaded function called product. The first function should accept two doubles that multiples them together. The second function should accept three doubles that multiples them together.
Solution
Product.cpp
#include <iostream>
using namespace std;
double product(double a, double b){
return a * b;
}
double product(double a, double b, double c){
return a * b * c;
}
int main()
{
cout<<\"Product with 2 parameters: \"<<product(2.2, 4.4)<<endl;
cout<<\"Product with 3 parameters: \"<<product(2.2, 4.4, 6.6)<<endl;
return 0;
}
Output:
sh-4.3$ g++ -std=c++11 -o main *.cpp
sh-4.3$ main
Product with 2 parameters: 9.68
Product with 3 parameters: 63.888
