Read only variable is not assignable
Mar 13, 2015 at 9:57pm UTC
I've been researching and I'm still puzzled on how this error (Read only variable is not assignable) works. I'm trying to increment a private pointer and dereference it to get it's value.
1 2 3 4 5 6 7 8 9 10 11 12 13
// private variables
private :
int deg;
double * coeff;
};
// Implementation
double Polynomial::coefficient(const int poly_pow) const {
double poly_coeff = *coeff++;
return poly_coeff;
}
Last edited on Mar 13, 2015 at 9:58pm UTC
Mar 13, 2015 at 10:04pm UTC
Im not 100% sure. But since your function is const
You cant increase/decrease or change a value at all inside there.
Also just wondering, why would the function take in const int poly_pow
And then not use it?
Mar 13, 2015 at 10:44pm UTC
@Tarik,
I figured it was the const! Thanks :)
Topic archived. No new replies allowed.