I've searched Google and have not found a solution to my problem. Function is to take a parameter and do a calculation on it. Based on the initial conditions it is supposed to return true and the the value calculated via a reference parameter.

Basic code before all modification to get the value returned.

bool discr(double array2[3]){
    double discr;
    if(array2[0] != 0){
         discr = pow(array2[1], 2) - 4*array2[0]*array2[2];
         cout << "\nProbe: discr " << discr[0] << "     " << discr[1];
         return true;
    }
    else
         return false;    
}

Many thanks in advance.

start with this

bool discr(double array2[3], double &result)

do you know how to use c++ references?

start with this

bool discr(double array2[3], double &result)

do you know how to use c++ references?

Are references less or more efficient than using pointers? Also, if I were to call this function, would the second parameter be simple of type double? or would it be double*?

Are references less or more efficient than using pointers?

I think it's more efficient than using pointer.

Also, if I were to call this function, would the second parameter be simple of type double? or would it be double*?

just be double.

bool discr(double array2[3]){
}

.

you can not pass an array to a function without tell the number of the array elements, otherwise, the number of the array elements will be unknown in the function.

you should define the function like this

bool discr(double array2[], int arrNum)
{
  .....
}
This article has been dead for over six months. Start a new discussion instead.