Code:
//copy constructor
Polynomial::Polynomial (const Polynomial & p) {
Polynomial newP;
newP.numTerms = p.numTerms;
this->numTerms = newP.numTerms;
newP.head = p.head;
this->head = newP.head;
}
//copy constructor
Polynomial::Polynomial (const Polynomial & p) {
Polynomial newP;
newP.numTerms = p.numTerms;
this->numTerms = newP.numTerms;
newP.head = p.head;
this->head = newP.head;
}
//copy constructor
Polynomial::Polynomial (const Polynomial & p) {
int newNumTerms;
Term * newHead;
newNumTerms = p.numTerms;
this->numTerms = newNumTerms;
newHead = p.head;
this->head = newHead;
}
//Polynomial assignment operator
Polynomial Polynomial::operator*(const Polynomial &p) {
//the newPoly polynomial will be the product of our two polynomials
Polynomial * newPoly = new Polynomial;
Term * temp1 = this->head;
Term * temp2 = p.head;
double c = 0;
int d = 0;
//we first multiply the
//destructor
Polynomial::~Polynomial () {
while (this->head != 0) {
del();
}
this->numTerms = 0;
}
Polynomial Polynomial::operator*(const Polynomial &p) {
Polynomial newPoly;
Term * temp1 = this->head;
Term * temp2 = p.head;
double c = 0;
int d = 0;
for (int i = 0; i < this->numTerms; i++) {
for(int j = 0; j < p.numTerms; j++) {
c = temp1->coeff * temp2->coeff;
d = temp1->deg
void Polynomial::orderDescending(){
Polynomial newPoly;
newPoly.head = this->head;
Term * temp1 = this->head;
Term * temp2 = temp1->next;
for (int
double closestNumber (double num); double closestNumber (const double& num)const;
Leave a comment: