Guest User

Untitled

a guest
Nov 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Point
  6. {
  7. public:
  8. Point();
  9. Point(int n);
  10. Point(int x, int y);
  11. Point(int n, Point temp);
  12. Point(Point tmp_a, Point tmp_b);
  13.  
  14. void operator=(Point& temp);
  15.  
  16. void Show();
  17.  
  18. ~Point() = default;
  19.  
  20. private:
  21. int x, y;
  22. };
  23.  
  24. Point::Point() : x(0), y(0) {}
  25.  
  26. Point::Point(int n) : x(n), y(n) {}
  27.  
  28. Point::Point(int x, int y) : x(x), y(y) {}
  29.  
  30. Point::Point(int n, Point temp)
  31. {
  32. x = temp.x * n;
  33. y = temp.y * n;
  34. }
  35.  
  36. Point::Point(Point tmp_a, Point tmp_b)
  37. {
  38. x = tmp_a.x + tmp_b.x;
  39. y = tmp_a.y + tmp_b.y;
  40. }
  41.  
  42. void Point::operator=(Point& temp)
  43. {
  44. x = temp.x;
  45. y = temp.y;
  46. }
  47.  
  48. void Point::Show()
  49. {
  50. cout << "(" << x << ", " << y << ")" << '\n';
  51. }
  52.  
  53. int main(int argc, char * argv[])
  54. {
  55. Point p1;
  56. Point p2(1);
  57. Point p3(2, 4);
  58. Point p4 = p3;
  59. Point p5(3, p2);
  60. Point p6(p3, p5);
  61.  
  62. p1.Show();
  63. p2.Show();
  64. p3.Show();
  65. p4.Show();
  66. p5.Show();
  67. p6.Show();
  68.  
  69. return 0;
  70. }
Add Comment
Please, Sign In to add comment