Question: Task 2: Extend the class. ---- PREVIOUS CODE BELOW - Modify the class declaration and definition to overload the +, -, *, / and ==
Task 2: Extend the class. ---- PREVIOUS CODE BELOW
- Modify the class declaration and definition to overload the +, -, *, / and == operators to correctly perform those calculations.
- The + and - operators should accept an input parameter of the same class type and return void. This operation should update the contents of that instance.
- The * and / operators should accept an input parameter of the same type as the private variables holding the x and y values. This will be a scaler multiplication/division, not a vector multiplication/division.
- The == operator should accept an input parameter of the same class type and return a bool indicating if the value is equivalent.
- Modify the class declaration and definition to include a member function returning the magnitude and another returning the angle of the vector.
- You will likely have to change the class declaration beyond the new functions being defined in this task
THEN
Create a program that tests the class.
- Prompt the user for x and y values for the vector.
- Prompt the user for the operation to perform.
- Prompt the user for the values for other vector or scaler to be used in the calculation.
- Display the results (x, y, magnitude and angle of the resultant vector).
- Ask the user if they wish to continue. If so, loop to step b.
- Use your test program to test all member functions and ensure the class is working correctly.
- Test of all operator overload functions.
MyVector.h --------- #ifndef MyVector_h #define MyVector_h #include
MyVector.cpp -------- #include "MyVector.h" #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
