Answered step by step
Verified Expert Solution
Link Copied!

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 non-member 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 0 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 (1,2).
(f) Define the following overloaded operators which are non-member functions:
i. Define an overloaded operator for Vector operator +(const Vector &v1, const Vector &v2) which
can perform vector summation and return a Vector object. (Let v1=(x1, y1) and v2=(x2, y2), then
v1+ v2=(x1+ x2, y1+ y2))
ii. Define an overloaded operator for Vector operator -(const Vector &v1, const Vector &v2) which
can perform vector difference and return a Vector object. (Let v1=(x1, y1) and v2=(x2, y2), then
v1 v2=(x1 x2, y1 y2))
iii. Define an overloaded operator for Vector operator -(const Vector &v1) which returns a Vector ob-
ject which will be in the opposite direction of v1.
iv. Define an overloaded operator for bool operator ==(const Vector &v1, const Vector &v2) 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Iv Special Issue On Database Systems For Biomedical Applications Lncs 6990

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Christian Bohm ,Johann Eder ,Claudia Plant

2011th Edition

3642237398, 978-3642237393

More Books

Students also viewed these Databases questions

Question

Please show the schematics design for the questions

Answered: 1 week ago

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago