![]() Of a default maximum degree, say called DEF_MAX_DEGREE. Using a dynamically-allocated array large enough to hold a polynomial The default (no-argument) constructor will create a Polynomial ![]() That stores the maximum degree that a Polynomial object can hold. You will need to add a data member, say called maxDegree, Modify the data members of the Polynomial class to use a dynamically-allocated array. The following paragraphs describe these enhancements That allows the maximum degree of a Polynomial to be changedĪfter it is created. The second enhancement is to provide a resize( ) member function This enhancement is similar to the List class described in section 6.3 of your textbook. This is accomplished by using a dynamically-allocated array in the class,Īnd by providing a constructor function that allows you to The first is to allow programmers to create Polynomials of any maximum degree. ![]() Your assignment is to make two enhancements to this class. ![]() You cannot have a Polynomial with degree larger than MAX_DEGREE. That is, they all have the same upper limit on the degree. This class has the limitation that all Polynomials have the same "physical size". It can represent a polynomial of any degree up to and including MAX_DEGREE (a global constant defined with the class). (similar to the List class in section 6.2 of your textbook). A polynomial of degree n has n + 1 coefficients.Īn array of size k can hold the coefficients for a polynomial of degree k - 1 (or a smaller degree).īelow you will find code for a Polynomial class that uses an array to hold the polynomial coefficients One way to represent a polynomial is to use an array to hold the coefficients. ![]() Note that a polynomial with degree 2 is called a quadratic polynomial. Note that x 1 is the same as x, and x 0 is 1.Ī polynomial whose coefficients are all zero has degree -1. The highest exponent with non-zero coefficient, n, is called the degree of the polynomial.Ġx 2 + 2x + 3 is normally written as 2x + 3 and has degree 1. , a 2, a 1, and a 0 are constants called the coefficients of the polynomial. Where x is a variable that can take on different numeric valuesĪnd a n. I will not make any changes unless I find problems.īe sure to read through Section 6.3 in your textbook before starting this assignment.Ī polynomial in one variable is an arithmetic expression of the form Program 2 - Polynomial Class with a Dynamic Arrayįinal version. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |