Read only variable is not assignable

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
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?
@Tarik,

I figured it was the const! Thanks :)
Topic archived. No new replies allowed.