So I'm making a function to differentiate a polynomial. Here's the function:
void differentiate (double coefficients[], int & degree);
void differentiate (double coefficients[], int & degree){
int *p_n{°ree};
int p{*p_n};
coefficients[p]=0;
for (int i=0;i<p+1;i++){
coefficients[i]=(coefficients[i+1])*(i+1);
}
}
And this is my main()
function:
int main(){
double arr[3]{3,1,5};
std::cout<<differentiate(arr,2)<<std::endl;
}
However, when I try to use this function in my main()
function, it gives me this error saying:
initial value of reference to non-const must be an lvalue
I'm pretty sure it has something to do with the pointer, but I'm not sure what.