I am trying to do an exercise that will evaluate 2 numbers and return the largest.
However, the function that evaluates and returns the largest number can only have 2 parameters.
Both of which are pointers to cont double, yet the function is to return a pointer to double, not const double.
I have done something similar before and am supposed to do the evaluation using the ternary operator.
However I dont fully understand how pointers work.
Any Pointers about Pointers?
here is my code
#include <cstdlib>
#include <iostream>
using namespace std;
double ComputeMaximum(double *num1, double *num2)
{
return((*num1 < *num2) ? *num2 : *num1);
}
int main()
{
const double numToEval_1 = 6.9;
const double numToEval_2 = 6.5;
double *pointToNum1 = numToEval_1;
double *pointToNum1 = numToEval_2;
computeMaximum(*numToEval_1, *numToEval_2);
cout << "%f", num1
system("PAUSE");
return EXIT_SUCCESS;
}

New Topic/Question
Reply



MultiQuote







|