fork(1) download
  1. /*****************************************************************
  2. Name :
  3. Date : 2017/02/22
  4. By : CharlotteHonG
  5. Final: 2017/02/22
  6. *****************************************************************/
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. struct Point{
  11. Point(int a=1, int b=1): x(a), y(b) {}
  12. Point & operator+=(Point const &rhs){
  13. x += rhs.x;
  14. y += rhs.y;
  15. return *this;
  16. }
  17. int x, y;
  18. };
  19. Point const & operator+(Point const &lhs, Point const &rhs){
  20. return Point(lhs) += rhs;
  21. }
  22. /*==============================================================*/
  23. int main(int argc, char const *argv[]){
  24. Point p1;
  25. Point p;
  26. p=p+p1;
  27. cout << p.x << endl;
  28. cout << p1.x << endl;
  29.  
  30. return 0;
  31. }
  32. /*==============================================================*/
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0
1