Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is an assignment for C++ overloading operator, please fully develop polynomial.h and polynomial.cpp , thank you! Develop class Polynomial. The internal representation of a

Here is an assignment for C++ overloading operator, please fully develop polynomial.h and polynomial.cpp, thank you!

Develop class Polynomial. The internal representation of a Polynomial is an array or vector of terms. Each term contains a coefficient and an exponent, e.g., the term

2x^4 has the coefficient 2 and the exponent 4. Develop a complete class containing proper constructor and destructor functions as well asset and get functions. The class should also provide the following overloaded operator capabilities:

a.Overload the addition operator (+) to add two Polynomials.

b.Overload the subtraction operator (-) to subtract two Polynomials.

c.Overload the assignment operator(=) to assign one Polynomial to another.

d.Overload the addition assignment operator (+=).

e.Overload the subtraction assignment operator (-=).

Beyond overloading these operators, the code in the polynomial_app.cpp will give you an idea of what member functions you need to implement in the Polynomial class.

Below is Polunomial_app.cpp:

#include

#include "Polynomial.h"

using namespace std;

int main()

{

Polynomial a, b, c, t;

a.enterTerms();

b.enterTerms();

t = a; // save the value of a

cout << " First polynomial is: ";

a.printPolynomial();

cout << " Second polynomial is: ";

b.printPolynomial();

cout << " Adding the polynomials yields: ";

c = a + b;

c.printPolynomial();

cout << " += the polynomials yields: ";

a += b;

a.printPolynomial();

cout << " Subtracting the polynomials yields: ";

a = t; // reset a to original value

c = a - b;

c.printPolynomial();

cout << " -= the polynomials yields: ";

a -= b;

a.printPolynomial();

cout << endl;

system("PAUSE"); //remove this if you are not using windows

return 0;

} // end main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

Describe the costs associated with a lack of or inadequate HRP.

Answered: 1 week ago

Question

How could assessment be used in an employee development program?

Answered: 1 week ago