Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <windows.h>
- using namespace std;
- class A
- {
- protected:
- int a;
- int b;
- public:
- A(int aa,int bb):a(aa),b(bb) {}
- ~A()
- {
- cout << "Деструктор А." << endl;
- }
- };
- class B :public A
- {
- public:
- B(int aa,int bb):A(aa,bb) {}
- void task ()
- {
- double c;
- __try
- {
- if (b == 0)
- {
- RaiseException(EXCEPTION_PRIV_INSTRUCTION, 0, 0, NULL);
- }
- c = a / b;
- cout << "c= " << c << endl;
- }
- __except (EXCEPTION_EXECUTE_HANDLER)
- {
- cout << "Деление на ноль." << endl;
- }
- }
- ~B()
- {
- cout << "Деструктор В." << endl;
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- B a(1, 0);
- a.task();
- B b(4, 2);
- b.task();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement