B
beachlounger
What the heck is wrong with this:
#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
class Polynomial {
public:
Polynomial();
Polynomial operator+( const Polynomial& ) const; // addition
Polynomial operator-( const Polynomial& ) const; // subtraction
Polynomial operator*( const Polynomial& ); // multiplication
const Polynomial operator=( const Polynomial&);// assignment
Polynomial& operator+=( const Polynomial& );
Polynomial& operator-=( const Polynomial& );
Polynomial& operator*=( const Polynomial& );
void enterTerms();
void printPolynomial() const;
private:
int exponents[ 100 ]; // exponent array
int coefficients[ 100 ]; // coefficients array
void polynomialCombine( Polynomial& ); // combine common terms
}; // end class Polynomial
#endif
#include <iostream>
using std::cout;
using std::endl;
#include "Polynomial.h"
int main()
{
Polynomial a, b, c, t;
a.enterTerms();
b.enterTerms();
t = a; // save the value of a
cout << "First polynomial is:\n";
a.printPolynomial();
cout << "Second polynomial is:\n";
b.printPolynomial();
cout << "\nAdding the polynomials yields:\n";
c = a + b;
c.printPolynomial();
cout << "\n+= the polynomials yields:\n";
a += b;
a.printPolynomial();
cout << "\nSubtracting the polynomials yields:\n";
a = t; // reset a to original value
c = a - b;
c.printPolynomial();
cout << "\n-= the polynomials yields:\n";
a -= b;
a.printPolynomial();
cout << "\nMultiplying the polynomials yields:\n";
a = t; // reset a to original value
c = a * b;
c.printPolynomial();
cout << "\n*= the polynomials yields:\n";
a *= b;
a.printPolynomial();
cout << endl;
return 0;
} // end main
C:\Documents and Settings\Owner\connie marshall's week 7
homework.cpp(32) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory
The question is:
Using C++ language to complete this homework
1. Develop class Polynomial. The internal representation of a
Polynomial is an array of terms. Each term contains a coefficient and
an exponent. The term
2x4
has the coefficient 2 and the exponent 4. Develop a complete class
containing proper constructor functions as well as set 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 multiplication operator (*) to multiply two
Polynomials.
(c) Overload the subtraction assignment operator (-) to process two
Polynomials
(d) Overlaod the assignment operator to assign one polynomial to
another
(e) Overload the addition assignment operator (+=), subtraction
assignment operator (-=), and multiplication assignment operator(*=).
I'm going crazy here. Please help.
#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
class Polynomial {
public:
Polynomial();
Polynomial operator+( const Polynomial& ) const; // addition
Polynomial operator-( const Polynomial& ) const; // subtraction
Polynomial operator*( const Polynomial& ); // multiplication
const Polynomial operator=( const Polynomial&);// assignment
Polynomial& operator+=( const Polynomial& );
Polynomial& operator-=( const Polynomial& );
Polynomial& operator*=( const Polynomial& );
void enterTerms();
void printPolynomial() const;
private:
int exponents[ 100 ]; // exponent array
int coefficients[ 100 ]; // coefficients array
void polynomialCombine( Polynomial& ); // combine common terms
}; // end class Polynomial
#endif
#include <iostream>
using std::cout;
using std::endl;
#include "Polynomial.h"
int main()
{
Polynomial a, b, c, t;
a.enterTerms();
b.enterTerms();
t = a; // save the value of a
cout << "First polynomial is:\n";
a.printPolynomial();
cout << "Second polynomial is:\n";
b.printPolynomial();
cout << "\nAdding the polynomials yields:\n";
c = a + b;
c.printPolynomial();
cout << "\n+= the polynomials yields:\n";
a += b;
a.printPolynomial();
cout << "\nSubtracting the polynomials yields:\n";
a = t; // reset a to original value
c = a - b;
c.printPolynomial();
cout << "\n-= the polynomials yields:\n";
a -= b;
a.printPolynomial();
cout << "\nMultiplying the polynomials yields:\n";
a = t; // reset a to original value
c = a * b;
c.printPolynomial();
cout << "\n*= the polynomials yields:\n";
a *= b;
a.printPolynomial();
cout << endl;
return 0;
} // end main
C:\Documents and Settings\Owner\connie marshall's week 7
homework.cpp(32) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory
The question is:
Using C++ language to complete this homework
1. Develop class Polynomial. The internal representation of a
Polynomial is an array of terms. Each term contains a coefficient and
an exponent. The term
2x4
has the coefficient 2 and the exponent 4. Develop a complete class
containing proper constructor functions as well as set 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 multiplication operator (*) to multiply two
Polynomials.
(c) Overload the subtraction assignment operator (-) to process two
Polynomials
(d) Overlaod the assignment operator to assign one polynomial to
another
(e) Overload the addition assignment operator (+=), subtraction
assignment operator (-=), and multiplication assignment operator(*=).
I'm going crazy here. Please help.