axeefectushka

Untitled

Jan 20th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. Билет 24
  2. #include "stdafx.h"
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class first
  7. {
  8. private:
  9.     int a;
  10. public:
  11.     first(int aa) :a(aa)
  12.     {
  13.         cout << "Work!" << endl;
  14.     }
  15.     ~first()
  16.     {
  17.         cout << "Destructor!" << endl;
  18.     }
  19.     int& operator++()
  20.     {
  21.         a+=10;
  22.         return a;
  23.     }
  24.     int operator++(int)
  25.     {
  26.         int tmp = a;
  27.         a+=10;
  28.         return tmp;
  29.     }
  30.     void show()
  31.     {
  32.         cout << a << endl;
  33.     }
  34.     void show2()
  35.     {
  36.         cout << a++ << endl;
  37.     }
  38. };
  39.  
  40.  
  41.  
  42. int main()
  43. {
  44.     first a(5);
  45.     ++a;
  46.     a.show();
  47.     a.show2();
  48.     a.show2();
  49.     return 0;
  50. }
Add Comment
Please, Sign In to add comment