Question: C++ Assignment Didnt get how to do this part please help. (Please label parts, thank you) Given my code of Point 2D class: class Point2D

C++ Assignment

Didnt get how to do this part please help. (Please label parts, thank you)

Given my code of Point 2D class:

class Point2D { public: /* * Default Constructor * Places point at (0, 0) */ Point2D() { x = 0; y = 0; } /* * Constructor * Places point at (xCoord, yCoord) */ Point2D(int xCoord, int yCoord) { x = xCoord; y = yCoord; } int getX() { return x; } int getY() { return y; } void setX(int xCoord) { x = xCoord; } void setY(int yCoord) { y = yCoord; } void moveHorizontally(int distance) { x+=distance; } void moveVertically(int distance) { y+=distance; } void moveToOrigin() { x = y = 0; } /* * Prints the current location of the point * */ void printLocation() { cout<<"Point located at ("<

Now,

1) Create a vector to store Point2D points and then

a. Write a function printAll which takes as a parameter a vector of Point2D objects and prints all their locations. The function returns nothing.

b. Write a function moveAll that takes as a parameter a vector of Point2D objects, and two int parameters moveX and moveY and moves all the points by moveX and moveY. The function returns nothing. Create a vector of points in the main and add 3 points to it. Call the function to move all the points by -2, 5. Then, call the printAll function and verify that they have moved.

2) Write a function combine which takes two vectors of student names (create a vector for student names) , group1 and group2 and returns a vector containing all the students in both groups. Call your function from the main with two groups you create and then print the result returned from the function.

3) Describe briefly what exceptions are and what their purpose is. What is the try block? What is the catch block? What happens with the flow of control if the catch block does not catch a thrown exception? Give a simple example.

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!