Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program which has the following properties with non - member overloaded operators detailed below: ( a ) Define a class called Vector which
Write a program which has the following properties with nonmember overloaded operators detailed below:
a Define a class called Vector which has integer x and y private members. Please note that this Vector class has
nothing to do with the vector class in C
b Define your getter and setter functions. Please make the getter functions const once you make sure that things
are working
c Define a default constructor which initializes x and y with by using initialization list.
d Define a constructor which initializes both x and y with user defined values initialization list.
e Define a display function which displays x and y components of your vector objects in parentheses like
f Define the following overloaded operators which are nonmember functions:
i Define an overloaded operator for Vector operator const Vector &v const Vector &v which
can perform vector summation and return a Vector object. Let vx y and vx y then
v vx x y y
ii Define an overloaded operator for Vector operator const Vector &v const Vector &v which
can perform vector difference and return a Vector object. Let vx y and vx y then
v vx x y y
iii. Define an overloaded operator for Vector operator const Vector &v which returns a Vector ob
ject which will be in the opposite direction of v
iv Define an overloaded operator for bool operator const Vector &v const Vector &v which
checks if two vectors are the same and returns either true or false. Youre going to check whether the corre
sponding components are the same
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started