I have a class to create an object that forms a polynomial of any degree.
And the class with its private part would be like this according to the example I'm trying to understand:
class polinomio
{
public:
//...
private:
double* coeficiente;
unsigned gradoMax;
unsigned grado;
};
Therefore I understand that:
unsigned gradoMax;
takes care of keeping the maximum degree of the polynomial.
unsigned grado;
If I'm not mistaken, it is the current degree that a coefficient has at a given moment. For example, if the polynomial is of degree 3 and I want to check what coefficient it has in degree 2, then this attribute will have a value of degree 2.
I think that coefficient is a vector of coefficients in which, according to its position in the vector, it will correspond to the independent term (degree 0), coefficient of degree 1 (position 1 of the vector) but in reality a pointer is declared there but... to what? This is what I can't understand:
double* coeficiente
What does that pointer do? Where does it point? Am I on the right track according to what I have stated above to achieve a polynomial object?
Thank you very much.
CLARIFICATION/EXTENSION
I have already managed to know what each thing consists of:
double *coeficiente;
It is a pointer that points to a dynamic vector with the coefficients, in the position i of the vector it will store the degree i.
unsigned gradoMax;
It is the maximum degree that can be stored.
unsigned grado;
It is the degree of the stored polynomial. It is the highest value of the index in the coefficient vector.
Therefore, in order not to open another question, I continue with the doubt, if you create a pointer within a class, as in the case of double *coeficiente;
Where is the dynamic vector created? I can't understand that.
Thanks again.