Advertisement
sddd

fakaaa

Jan 25th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. // test6.cpp: определяет точку входа для консольного приложения.
  2.  
  3. https://app.box.com/s/egjyhtyj6sx7fjpdt7wv1s5s3xyh9isy
  4. ==========================================================
  5.  
  6. #include "stdafx.h"
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. class MyClass
  12. https://app.box.com/s/egjyhtyj6sx7fjpdt7wv1s5s3xyh9isy
  13. =============================================================
  14. {
  15. public:
  16. int value;
  17.  
  18. MyClass(int value = 0)
  19. {
  20. this->value = value;
  21. }
  22.  
  23. friend MyClass operator ++(MyClass&);
  24. friend MyClass operator -(MyClass&, MyClass&);
  25.  
  26. void show(MyClass&);
  27. ~MyClass()
  28. {
  29.  
  30. https://app.box.com/s/egjyhtyj6sx7fjpdt7wv1s5s3xyh9isy
  31. ===============================================================
  32. }
  33. };
  34.  
  35.  
  36. MyClass operator++ (MyClass& a1)
  37. {
  38. return MyClass(a1.value++);
  39. }
  40.  
  41.  
  42. MyClass operator -(MyClass a1, MyClass a2)
  43. {
  44. return MyClass(a1.value - a2.value);
  45. }
  46.  
  47.  
  48. void MyClass::show(MyClass& obj)
  49. {
  50. cout << "value = " << obj.value << "\n";
  51. }
  52.  
  53.  
  54. int main()
  55. {
  56. MyClass a1(5);
  57. MyClass a2(3);
  58. MyClass a3;
  59.  
  60. a3 = a1++ - a2;
  61.  
  62. a1.show(a1);
  63. a2.show(a2);
  64. a3.show(a3);
  65.  
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement