Class Polynomial

Hello,everybody.I'm a beginner in C++
I'm working on "Class Plynomial"
I can write + , - , / ,....operators ,but I can't write operator *(times)
1
2
3
4
5
6
7
8
9
10
template<class T>
Class Polynomial:Public Array<T>
{
   Public:
     Polynomial& operater *(Polynomial &P)
{

//////////Code 
 }
};

Please,Help me finish * operator
Thanks a lot.
Last edited on
If I understand you correctly, you represent a polynomial by the coefficients. ax2+bx+c would be stored as [a, b, c]. Then let's try multiplying:

e*(ax2+bx+c) = aex2+bex+ce
the reslut: [a*e, b*e, c*e] - every element was multiplied by e

ex*(ax2+bx+c) = aex3+bex2+cex + 0
the reslut: [a*e, b*e, c*e, 0] - array shifted left and then was multiplied by e.
(ax2+bx+c)*(dx+e) = dx*(ax2+bx+c) + e*(ax2+bx+c)
the reslut - the sum of previous two.

good luck
thanks' Hamsterman'
you understood my ideal.but i want to build Class Ploynomial with opearators +,-,*,/(plus,minus,time,...)
Write a function that shifts an array, write a function that multiplies every element by something.
1
2
3
4
5
6
Polynomial operator *(Polynomial a, Polynomial b){
    Polynomial result;
    for(int n = 0; n < b.length(); n++)
        result = result + shift( multiply(result, b[n]), n);
    return result;
}
Topic archived. No new replies allowed.