Operators Overloading


Download 26.89 Kb.
Sana20.06.2023
Hajmi26.89 Kb.
#1628302
Bog'liq
assignment 2





Operators Overloading

Similar to exercise #1 (you can review it).


In this exercise you’ll be working with rational numbers of polynomials with one variable “x”.



Example:

A polynomial example can be:


1 +x2 − 2 · x ·p(x)=3

A rational number example (with polynomials):


Every polynomial will be represented as an instance of the Polynomial Class. Every instance of the Polynomial type is defined by its “maximum degree”. In the above example, the polynomial can be represented by an instance of degree 2 and above.


A rational number (an instance of Rational Class) should be represented by two Polynomials (which represent the “numerator” and the “denominator”).

Add for both classes Polynomial and Rational the Operator Overloading of “+”, “-“, “*”, “=”. In addition add two operators “[ ]” (with and without const) so it will allow reading and changing the coefficients of a polynomial.


  • In the moodle there’s a file called “Main.cpp”. This file shouldn’t be changed during your development.

  • Design and develop the necessary classes (Polynomial and Rational) and split their declaration and definitions in the next files (polynomial.h, polynomial.cpp, rational.h, rational.cpp).

  • After development of the project is complete execute the program (with the “main.cpp” file and compare that the results you get are exactly as they appear in the attached “result.jpg” file).


YOU SHOULD NOT USE A CLASS A MONOM TYPE! THE POLYNOMIAL CLASS SHOULD NOT HAVE ANY OBJECT OF ANY OTHER CLASS!

Submission Requirements


  • The submission should not include any other files except the “.h” and “.cpp” files that you’ve developed. The submission should be just 1 ZIP file including these relevant files.

  • Similar/Copied submissions will be check and may get disqualified.

Download 26.89 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling