axeefectushka

Untitled

Jan 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. protected:
  7.     int a;
  8.     int b;
  9. public:
  10.     A(int aa, int bb) :a(aa), b(bb) {}
  11.     ~A()
  12.     {
  13.         cout << "D A!" << endl;
  14.     }
  15. };
  16.  
  17. class B :public A
  18. {
  19. public:
  20.     B(int aa, int bb) :A(aa, bb) {}
  21.     void operator ++()
  22.     {
  23.         int tmp = a, tmp2 = b;
  24.         ++a; ++b;
  25.         cout << "a= " << tmp << " b= " << tmp2 << endl;
  26.     }
  27.     void operator ++(int)
  28.     {
  29.         ++a; ++b;
  30.         cout << "a=" << a << " b=" << b << endl;
  31.     }
  32.     void show()
  33.     {
  34.         cout << "a= " << a << " b= " << b << endl;
  35.     }
  36.     ~B()
  37.     {
  38.         cout << "D B!" << endl;
  39.     }
  40. };
  41.  
  42.  
  43. int main()
  44. {
  45.     B a(0, 1);
  46.     a.show();
  47.     a++;
  48.     ++a;
  49.     a.show();
  50.     system("pause");
  51.     return 0;
  52. }
Add Comment
Please, Sign In to add comment