private: int coefficients_[10]; //Prints out the coefficient to the output. void show(Polynomial* p) { cout << "Coefficients are: " << p->coefficients_[0]; for (int i=1; i<10; i++) { cout << "," << p->coefficients_[i]; } cout << endl; //Calling the constructor Polynomial *a; a = new Polynomial("-12 + 7x2 + 7x9 - 21x5 - 11x7"); show(a); //User-defined constructor that creates an object with the given string polynomial. Polynomial::Polynomial( const char *ps){ int i = 0; int coeff = 0; int subscript = 0; char* rest; char* cCoeff; char* cScript; char pString[81]; //copy input arg to temporary string strcpy(pString, ps); //get coefficient cCoeff = strtok(pString, " x"); //convert to int coeff = atoi(cCoeff); //get rest of the string, this is where i get stuck. How do i check to see if there's an x in the term?? rest = strpbrk(pString, cCoeff); //get subscript cScript = strtok(rest," "); //convert to int subscript = atoi(cScript); //insert in array object coefficients_[subscript] = coeff; // i know i need a loop of some sort to get the remainding terms }

Thank you for any hints or tips