I am trying to decide how to represent the Polynomialclass. The problems states that the Polynomial is an array ofterms. Each term has a coefficent and anexponent. Should I have the Polynomial contain an array of PolyTermwhere Class PolyTerm { double coef; int exponent; } Or could I use instead class Polynomial { private: int size; double* coef; } and the index of the coef is the exponent? I am trying to decide how to represent the Polynomialclass. The problems states that the Polynomial is an array ofterms. Each term has a coefficent and anexponent. Should I have the Polynomial contain an array of PolyTermwhere Class PolyTerm { double coef; int exponent; } Or could I use instead class Polynomial { private: int size; double* coef; } and the index of the coef is the exponent?
Explanation / Answer
//Hope this will help you.. #include using namespace std; class PolyTerm { private: double coef[100]; int exponent[100]; int len; public: void get() /*take input from user*/ { int i; coutlen; for(i=0;i