Question: C++ only In this task you are going to make a class for 2D-Vectors called TwoDVector. Vectors can be thought of in multiple ways but

C++ only

In this task you are going to make a class for 2D-Vectors called TwoDVector.

Vectors can be thought of in multiple ways but for this task, just think of them as two real numbers a and b represented as with certain properties.

You also need to make the following function members (or methods):

Default constructor with no parameters. Set the two values of the vector to 0.0 in this case.

A parameterized constructor with two parameters corresponding to the two values of the vector.

A destructor. This destructor will do nothing in this case.

A printTwoDVector() function that prints the object of this class as . For example, <2,5>. 2 Appropriate setter and getter functions.

A method that returns the norm of the vector. Norm of a 2d vector is defined as a2 + b2.

Overload + operator so that two objects of this class can be summed up with + operator. For example, vec1 + vec2 should return the sum such that if vec1 is and vec2 is then the method returns an object that represents .

Overload operator so that two objects of this class can be subtracted with operator. For example, vec1 vec2 should return the difference such that if vec1 is and vec2 is then the method returns an object that represents .

Overload * operator so that two objects of this class can be multiplied as a dot product operation with * operator. For example, vec1 * vec2 should return the dot product such that if vec1 is and vec2 is then the method returns a number that represents the dot product, in this case .

You may declare and define other helper functions and methods that may help you. Add appropriate code in the main function so that it can demonstrate the functions of the class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!