c++
2. Continuous of question 1. Implement operator overloading. Operator Overloading a) Implement two unary operator overload functions (−,+,!). b) Implement four arithmetic operator overload functions (+,−,∗,/). c) Implement six relational operator overload functions (==,!=,>,>=,<,<=). d) Implement the insertion operator overload function (≪<). e) Implement the extraction operator overload function (≫). f) Implement the subscript operator overload function ([]). Make sure that each function is optimally overloaded for its purpose. (pick between member, non-member, friend as appropriate) Notes Add Rational Numbers Given a/b+c/d : Step 1: Find the LCM of b and d. Step 2: Create a new Rational Number: ((a∗(LCM/b)+(c∗(LCM/d))/LCM. Step 3: Reduce the new Rational Number from step 2. Step 4: Return the new Rational Number. Subtract Rational Numbers Given a/b−c/d : Step 1: Find the LCM of b and d. Step 2: Create a new Rational Number: ((a∗(LCM/b)−(c∗(LCM/d))/LCM. Due date: Jul 17, 11:59 PM Step 3: Reduce the new Rational Number from step 2. Step 4: Return the new Rational Number.
Multiply Rational Numbers Given a/b * c/d : Step 1: Create a new Rational Number: (a∗c)/(b∗d). Step 2: Return the new Rational Number. Divide Rational Numbers Given a/b * c/d: Step 1: Create a new Rational Number: (a∗c)/(b∗d). Step 2: Return the new Rational Number. Compare Rational Numbers: greater than Determine if a/b>c/d : Step 1: Find the LCM of b and d. Step 2: If (a∗(LCM/b)>(c∗(LCM/d) return true, otherwise false. Compare Rational Numbers: less than Determine if a/b<c/d : Step 1: Find the LCM of b and d. Step 2: If (a∗(LCM/b)<(c∗(LCM/d) return true, otherwise false. Use following main function to test your program. (have to use this main function)
c++
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am