Im trying to write a function named ComputeMaximum that has two parameters, both of type pointer to constant double, and returns type pointer to double
I keep getting the following casting errors:
- invalid conversion from ‘const double*’ to ‘double*’
- cannot convert ‘double’ to ‘const double*’ for argument ‘1’ to ‘double* ComputeMaximum(const double*, const double*)’
#include <iostream>
using namespace std;
double *ComputeMaximum(const double *num1, const double *num2)
{
return ((double*)num1>num2?num1:num2);
}
int main()
{
double *max;
max = ComputeMaximum(6.4, 6.9);
cout << *max;
return 0;
}
if he actually wants to pass pointers and return a pointer (can’t think why unless this is homework) If you want const double you will need to put const before every use of the word double in this entire clip