Assignment 6: Type the following program, complete it if
necessary, and execute it.
#include
<iostream>
using
namespace std;
class Point {
private:
float x;
float y;
public:
Point();
Point(const Point &);
Point operator+(Point B);
friend ostream& operator<<(ostream&, const Point&);
};
Point::Point() {
cout <<
¡°I love him\n¡±;
}
Point::Point(const Point &
rhs) {
temp.x = rhs.x; temp.y = rhs.y;
cout
<< ¡°I hate him\n¡±;
}
Point
Point::operator+(Point op) {
Point temp;
temp.x = x + op2.x;
temp.y = y + op2.y;
return temp;
}
ostream&
operator<<(ostream& os, const Point& p) {
os <<
"(" << p.x << ","<<
p,y<<")\n";
return
os;
}
int main(){
Point
A(1.0,2.0), B(3.0,4.0), C;
C=A+B;
cout<<
C;
}
Oral
Test on April 5.