SOME TIPS/HELP please

hello,
I have to implement this function: void addTerm(double coeff, unsigned exponent);

and it has to:
// add term (coeff^exponent) to the polynomial;
// might just change coefficient of existing term,
// or might insert new term; maintains terms
// in order from greatest to least exponent

I really have no idea where to start. I just want some tips or any help at all to start.
have you defined a Polynomial class?

if not, you need to start there...
...either it's a class or a string or something else - hard to move forward without a definition.
yes i have.

this is everything i have rite now:

#ifndef POLY_H
#define POLY_H

class Poly {

public:

Poly() : first(0) { }

void addTerm(double coeff, unsigned exponent);


private:

struct Term {
double coeff;
unsigned exponent;
Term *next;

Term(double c=0, unsigned e=0) // Term constructor done
: coeff(c), exponent(e), next(0) { }
};

Term *first; // pointer to first polynomial term

void printAbsTerm(Term *t) const;
// a helper for print(), already done in poly.cpp
};

#endif
thanks for replying!
you should use code-tags to make it easier to read

ok - I see you have chosen to use a linked list to maintain your terms

1. for debugging purposes, I recommend you start by writing a method which will print out all your terms
2. try to implement your first requirement: // add term (coeff^exponent) to the polynomial;

repost your new code in code-tags, indented cleanly, and we'll go from there
Topic archived. No new replies allowed.