Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Point {
- int x;
- int y;
- public:
- Point() {}
- Point(int _x, int _y) {
- x = _x;
- y = _y;
- }
- void set_x(int _x) {
- x = _x;
- }
- void set_y(int _y) {
- y = _y;
- }
- int get_x() {
- return x;
- }
- int get_y() {
- return y;
- }
- Point operator + (Point tmp) {
- Point result(x + tmp.x, y + tmp.y);
- return result;
- }
- Point operator - (Point tmp) {
- Point result(x - tmp.x, y - tmp.y);
- return result;
- }
- Point operator * (Point tmp) {
- Point result(x * tmp.x, y * tmp.y);
- return result;
- }
- Point operator / (Point tmp) {
- Point result(x / tmp.x, y / tmp.y);
- return result;
- }
- bool operator < (Point tmp) {
- if(x < tmp.x and y < tmp.y) {
- return true;
- }
- else {
- return false;
- }
- }
- bool operator <= (Point tmp) {
- if(x <= tmp.x and y <= tmp.y) {
- return true;
- }
- else {
- return false;
- }
- }
- bool operator > (Point tmp) {
- if(x > tmp.x and y > tmp.y) {
- return true;
- }
- else {
- return false;
- }
- }
- bool operator >= (Point tmp) {
- if(x >= tmp.x and y >= tmp.y) {
- return true;
- }
- else {
- return false;
- }
- }
- bool operator == (Point tmp) {
- if(x == tmp.x and y == tmp.y) {
- return true;
- }
- else {
- return false;
- }
- }
- bool operator != (Point tmp) {
- if(x != tmp.x or y != tmp.y) {
- return true;
- }
- else {
- return false;
- }
- }
- friend ostream & operator << (ostream & stream, Point tmp);
- };
- ostream & operator << (ostream & stream, Point tmp) {
- stream << tmp.x << " ";
- stream << tmp.y;
- return stream;
- }
- int main()
- {
- Point p1(4, 4);
- Point p2(5, 3);
- cout << p1 << endl;
- cout << p2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement