- #1
- 4,652
- 37
Ugh! I'm working on my last homework assignment and I can't seem to even get off the ground.
The teacher created a class for rational numbers, and now we are working on some functions for a polynomial class which uses arrays of rationals from his class. My polynomials are arrays of coefficients with each stored at an index position representing the power of x the coefficient is multiplied to.
I'm embarrassed to ask for help because there are 4 files involved: the rational class header and implementation file and the polynomial class header and implementation file.
I know you people have better things to do this weekend, but if anyone is really bored, the assignment and files are here:
http://www.math.ucla.edu/~rclark/10a.1.05w/hw6/hw6.html
It's the polynomial.cpp file where we have to fill in the blanks.
One of the first things I tried to do was the operator overloading to define addition for polynomials. Here's what I tried:
So far, not so good. It would be a huge help if someone could help me get just this piece fixed up. Thanks,
MIH
The teacher created a class for rational numbers, and now we are working on some functions for a polynomial class which uses arrays of rationals from his class. My polynomials are arrays of coefficients with each stored at an index position representing the power of x the coefficient is multiplied to.
I'm embarrassed to ask for help because there are 4 files involved: the rational class header and implementation file and the polynomial class header and implementation file.
I know you people have better things to do this weekend, but if anyone is really bored, the assignment and files are here:
http://www.math.ucla.edu/~rclark/10a.1.05w/hw6/hw6.html
It's the polynomial.cpp file where we have to fill in the blanks.
One of the first things I tried to do was the operator overloading to define addition for polynomials. Here's what I tried:
Code:
// operator+
polynomial operator+(const polynomial & a,const polynomial & b)
{
polynomial c;
for (int num = 0; num < polynomial::SIZE; num ++) //fill array with zeros
c[num] = 0;
for (int i = 0; i < polynomial::SIZE; i ++) //compute sum
c[i] = a[i] + b[i];
return c;
}
MIH
Last edited by a moderator: