Facebook
From Mammoth Leech, 2 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 184
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. class Point {
  7. public:
  8.         int x;
  9.         int y;
  10. public:
  11.         Point(int a = 0, int b = 0) { x = a, y = b; }
  12.         Point operator+(Point p);
  13. };
  14.  
  15. Point Point::operator+(Point p) { // ?
  16.         Point tmp;       // ?
  17.         tmp.x = x + p.x; // ?
  18.         tmp.y = y + p.y; // ?
  19.         return tmp;  //?
  20. }
  21.  
  22. int main() {
  23.         Point p1(1, 2);
  24.         Point p2(3, 6);
  25.  
  26.         p1 = p1 + p2;
  27.         cout << p1.x << p1.y << endl;
  28. }