Note for programmer: 1.Write a separate main() function as a driver for each question. The driver should demonstrate all the required functionalities of a question. 2. Write a c++ code and do not use any String or Math libraries (such as cmath, cstring, string, etc.) and also do not use built-in functions (such as pow, etc.).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Note for programmer:

1.Write a separate main() function as a driver for each question. The driver should demonstrate all the required functionalities of a question.

2. Write a c++ code and do not use any String or Math libraries (such as cmath, cstring, string, etc.) and also do not use built-in functions (such as pow, etc.).

Q2: Operator Overloading for Polynomial Člass
Develop a class named Polynomial. The internal representation of a polynomial is
an array of terms. Each term contains a coefficient and an exponent. The term
2x4
has coefficient 2 and the exponent 4. For a third-degree polynomial
4x³ + 3x + 2
there are two terms and a constant. The first term has coefficient 4 and the exponent
3, the second term has coefficient 3 and the exponent 1, and the third is a constant
2. The detailed guideline to add/subtract polynomials can be found here.
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 addition operator (+=) to add two polynomials
d. Overload the subtraction operator (=) to subtract two polynomials.
e. Overload operator (=) to assign one polynomial to another.
f. Overload operator (==) to check if two polynomials are equal.
g. Overload the stream insertion (<<) to get input polynomial and stream
extraction operator (>>) to display the polynomial.
Define all overloaded operators (except for stream insertion '<<' and stream
extraction >>' operators) as member functions of the Polynomial class. The
overloaded function for stream insertion (<<) and stream extraction (>>) operator
should be non-member friend functions. You need to write three files
(polynomial.h, polynomial.cpp, and polynomialMain.cpp).
Transcribed Image Text:Q2: Operator Overloading for Polynomial Člass Develop a class named Polynomial. The internal representation of a polynomial is an array of terms. Each term contains a coefficient and an exponent. The term 2x4 has coefficient 2 and the exponent 4. For a third-degree polynomial 4x³ + 3x + 2 there are two terms and a constant. The first term has coefficient 4 and the exponent 3, the second term has coefficient 3 and the exponent 1, and the third is a constant 2. The detailed guideline to add/subtract polynomials can be found here. 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 addition operator (+=) to add two polynomials d. Overload the subtraction operator (=) to subtract two polynomials. e. Overload operator (=) to assign one polynomial to another. f. Overload operator (==) to check if two polynomials are equal. g. Overload the stream insertion (<<) to get input polynomial and stream extraction operator (>>) to display the polynomial. Define all overloaded operators (except for stream insertion '<<' and stream extraction >>' operators) as member functions of the Polynomial class. The overloaded function for stream insertion (<<) and stream extraction (>>) operator should be non-member friend functions. You need to write three files (polynomial.h, polynomial.cpp, and polynomialMain.cpp).
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY