CECS275 Lab 4

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (6 votes)

Using the Point class below, create these overloaded operators for it.

<<, >>, +, -, ==,!=.

class Point {

int x, y;

public:

 

Point(int xp, int yp){

x = xp;

y = yp;

}

 

Point(){}

 

void Print(){

cout << ‘(‘<<x<<‘,'<<y<<‘)’;

}

 

};

You code them directly in the class declaration.

<< is insertion, >> is extraction, + means add the two x values and the two y values and return them in a new Point, – means subtract the parameter x from this x, and the parameter y from this y, and return the difference in a new Point, == is a member-wise comparison for equality and != is its opposite.