Ugh! I'm working on my last homework assignment and I can't seem to even get off the ground.(adsbygoogle = window.adsbygoogle || []).push({});

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 [Broken]

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,Code (Text):

// 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

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: C++ assignment involving classes

**Physics Forums | Science Articles, Homework Help, Discussion**