i need to use the provided constructor(it must be char* as an argument). |
Fine, but you should know more about that class.
Why does it take a pointer to non-const?
Will it (the object) modify the pointed to data?
Does it assume one char, C-string, or something?
Does it take ownership of the pointed to memory?
I am creating a Polynomial class and i need to extract coefficients and exponents from a string(for example: "3x^2+5x+3"). |
That is a separate challenge. The std::string and std::istringstream are useful. (And std::regexp.)
The input has one or more
terms separated by + or -. A separator affects the term following it. There is no separator after the last term. There could be a separator before the first term
Each term contains coefficient. The 'x' is optional.
If there is 'x', then there could be '^'.
If there is '^', then there could be 'exponent'.
Can you have "7x^-3"? Can you have parentheses?
The point is that you should be able to split one string input into a list of terms (still strings) and then process each term separately (to create object(s) representing that term).