### Program.exe

The input numbers I put in does not work with instead it shows " the pointed number?(I think that's what it is called) versus my actual input. and I also get program.exe stopped working popupp window

Here are my codes
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138`` `````` #include using namespace std; #include #include "Polynomial.h" Polynomial:: Polynomial() { degree=0; coefficients=NULL; } Polynomial::Polynomial(int degree, const double* coefficients) { degree = degree; coefficients=coefficients; } Polynomial::Polynomial( const Polynomial& another) { degree=another.getDegree(); for(int i=degree;i>=0;i--) { coefficients[i]=another.coefficients[i]; } } Polynomial::~Polynomial() { delete coefficients; } void Polynomial::setDegree(int d) { if(d>=0) { degree = d; } else degree=0; } int Polynomial::getDegree(void) const { return degree; } void Polynomial::setCoeff(int order) { //double *coefficients; coefficients=new double[order]; double temp; for(int i=order;i>=0;i--) { cin>>temp; coefficients[i]=temp; } } /*void Polynomial::setCoefficients(const double *coef) { if(coef!=NULL) coefficients=NULL; else coefficients=NULL; return; } const double* Polynomial::getCoefficients(void) const { return coefficients; }*/ ostream& operator<<( ostream& out , const Polynomial& poly) { int temp; temp=poly.getDegree(); if(poly.coefficients==NULL) { cout<<"empty"; } else{ for(int i=temp;temp>=0;temp--) { cout<>( istream& in,Polynomial& caught) { int temp; cin>>temp; caught.setDegree(temp); caught.setCoeff(temp); return in; } const Polynomial& Polynomial:: operator=( const Polynomial& equate) { degree=equate.getDegree(); for(int i=degree;i>=0;i--) { coefficients[i]=equate.coefficients[i]; } return *this; } bool Polynomial::operator==( const Polynomial& boolequate) const { bool check=true; if(degree==boolequate.getDegree()) { for(int i=degree;i>=0;i--) { if(coefficients[i]==boolequate.coefficients[i]) { } else check=false; } } else return false; if(check==false) { return false; } else return true; }``````

Here is the output i received
 ``1234567`` ``````(1) Testing `cout << A': empty (2) Testing `cin >> A': Enter the polynomial (integer order then double coefficients): 2 2 0 2 (3) Second look at A: 278884242105282788842411052827888424010528 Press any key to continue . . .``````

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243`` ``````// Polynomial.h #ifndef POLYNOMIAL_H #define POLYNOMIAL_H //class ostream; //class istream; class Polynomial { friend ostream& operator<<( ostream& , const Polynomial& ); friend istream& operator>>( istream& , Polynomial& ); public: Polynomial(); Polynomial( int degree, const double* coefficients ); Polynomial( const Polynomial& ); ~Polynomial(); const Polynomial& operator=( const Polynomial& ); bool operator==( const Polynomial& ) const; void setDegree (int degree); int getDegree() const; void setCoeff(int order); //void setCoefficients(const double* coef); //const double* getCoefficients(void) const; private: int degree; double *coefficients; } // Beware! Very, very incomplete! ; #endif ``````

Testerr file
 ``12345678910111213141516171819202122232425262728293031323334353637`` ``````// TestThePoly.cpp #include using std::cout; using std::endl; using std::cin; using namespace std; #include "Polynomial.h" int main() { Polynomial A; cout << "(1) Testing `cout << A': " << A << endl; cout << "(2) Testing `cin >> A':\n"; cout << "Enter the polynomial (integer order then double coefficients):\n\t "; cin>>A; cout << endl; cout << "(3) Second look at A: " << A << endl; Polynomial B(A); cout << "(4) Testing `Polynomial B(A)': " << B << endl; double clist[]={8, 4.5, 1}; Polynomial C(2, clist); cout << "(5) Testing `Polynomial C(2, clist)': " << C << endl; Polynomial D=C; cout << "(6) Testing D = C): " << D << endl; cout << "(7) Testing A == B : " << (A==B ? "TRUE" : "FALSE") << endl; cout << "(8) Testing A == D : " << (A==D ? "TRUE" : "FALSE") << endl; return 0; }``````

HERe's directions

 ``123456789101112131415161718`` ``````I have provided a basic testing program, TestThePoly.cpp, and a header le, Polynomial.h, for a polynomial class called Polynomial. Your job is relatively easy: complete the class declaration in the header and then implement the functions that are in the header le and test them to to ensure they work as advertised. The testing program supplied is very basic. You will be expected to modify it and add some (two or three) more tests to ensure that all aspects of the new class are exercised. For those who may be confused, the \degree" of a polynomial is the highest degree of its terms. For instance 4x3 + 3x2 + 0:3x 􀀀 1:54 is a polynomial of degree 3. Note: In this example there is one more term than the degree of the polynomial. 1. The declaration should match the interface shown in the provided incomplete header file Polynomial.h. Please understand that the actual structure of the private mem- bers and functions of this class are up to you to design. Also, the degree of the polynomial can be any nonnegative integer value (from 0 up to the sky is the limit). 2. The behavior of the class and its methods should duplicate that shown by the example test application TestThePoly.cpp. Its associated program output is at the end of this fi le. ``````

Here's the desired outcome
 ``12345678910`` ``````(1) Testing `cout << A': empty (2) Testing `cin >> A': Enter the polynomial (integer degree then double coefficients): 3 -1 2.09 -5.3 -0.98 (3) Second look at A: -1x^(3) +2.09x^(2) -5.3x^(1) -0.98 (4) Testing `Polynomial B(A)': -1x^(3) +2.09x^(2) -5.3x^(1) -0.98 (5) Testing `Polynomial C(2, clist)': +1x^(2) +4.5x^(1) +8 (6) Testing D = C: +1x^(2) +4.5x^(1) +8 (7) Testing A == B : TRUE (8) Testing A == D : FALSE``````
Topic archived. No new replies allowed.