Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class A
- {
- protected:
- int a;
- int b;
- public:
- A(int aa, int bb) :a(aa), b(bb) {}
- ~A()
- {
- cout << "D A!" << endl;
- }
- };
- class B :public A
- {
- public:
- B(int aa, int bb) :A(aa, bb) {}
- void operator ++()
- {
- int tmp = a, tmp2 = b;
- ++a; ++b;
- cout << "a= " << tmp << " b= " << tmp2 << endl;
- }
- void operator ++(int)
- {
- ++a; ++b;
- cout << "a=" << a << " b=" << b << endl;
- }
- void show()
- {
- cout << "a= " << a << " b= " << b << endl;
- }
- ~B()
- {
- cout << "D B!" << endl;
- }
- };
- int main()
- {
- B a(0, 1);
- a.show();
- a++;
- ++a;
- a.show();
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment