Question: c++ help Lab 2: Vectors and Classes Create a class PosPoly that stores polynomials in x with positive integer coefficients. For example, 4x + 2x

c++ help

c++ help Lab 2: Vectors and Classes Create a class PosPoly thatstores polynomials in x with positive integer coefficients. For example, 4x +2x + 3x2 + x. The instance variables of your class should

Lab 2: Vectors and Classes Create a class PosPoly that stores polynomials in x with positive integer coefficients. For example, 4x + 2x + 3x2 + x. The instance variables of your class should be (a) a counter for the number of powers; and (b) a vector of Pair's, where a Pair is a struct (or a class) that stores two ints: the power and the coefficient. The powers should be in the order they were first added. For example, the above polynomial could be stored as: entry Count = 4 power 5 6 21... coeff 4 2 3 1 ... The class should be stored in files PosPoly.cpp and PosPoly.h. (The code for Pair can be in its own files, but it is also okay to include it in PosPoly.h. It is also okay to adapt/use the Pair class given on the class website as solution to Practice 2.) Your PosPoly class should have the following methods: A default constructor that initializes the polynomial to zero An overloaded using namespace std; #include "PosPoly.h" int main() PosPoly A, B; int cof, pow; bool is Done=false; cout > cof >> pow; isDone = (cofr=0 && pow==0); if(!isDone ) A.incrementBy( cof, pow ); isDone=false; cout > cof >> pow; isDone = (cof==0 && pow==0); if(!isDone) B.incrementBy( cof, pow ); cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!