Question: a) Which line in the class definition contains the constructor? b) Give the prototype and defintion for the overloaded + operator, that will add two

 a) Which line in the class definition contains the constructor? b)

a) Which line in the class definition contains the constructor?

b) Give the prototype and defintion for the overloaded + operator, that will add two points. You can define the addition of two points as follows: (x1,y1) + (x2,y2) = (x1+y1,x2+y2)

prototype:_____________________________________________

definition:

c) Assume the class defintion above, plus the added overloaded addition from question b). What is printed by the following code?

int main()

{

// Some points.

Point a(5.2, -4.8);

Point b(1.0, 9.0);

Point d; //look at default values

a.print();

b.print();

d.print();

cout

b.move(2,-5);

b.print();

(a + b).print();

cout

b.print();

cout

d.print();

cout

}

d ) Suppose that we want users to input a point in the following format (note that the numbers here are just examples; the user can input any doubles): (2,3.5) Give the prototype and definition for the overloaded >> operator.

prototype:____________________________________________________________

definition:

2) Here is a class definition for a Point class. Objects in the class represent points on the Cartesian Graph. 1 class Point 2 public Uses default arguments to allow calling with zero, one or two values. Point (double x 0.0, double y 0.0) Computes distance to another point using Pythagorean theorem. double dist (Point other) Move the existing point. void move (double a double b) //print the point nicely 10 void print 11 12 private: 13 double xval double val; 15 Point:: Point (double x, double y) xval yval void Point move (double a double b) xval val b; double Point dist (Point other) double xd J xval other. xval; double ya yval other yval return sart (xd*xd yd yd); void Point print cout

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!