Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string>
- #include <string.h>
- using namespace std;
- void foo1(int god) { //funkcuya bez isklycheniy
- cout<<"Funkcuya bez obrabotki isklycheniy!"<<endl;
- if (god % 100 == 0 && god % 400 == 0)
- cout << "God vusokosnuy!" << endl;
- else if (god % 100 != 0 && god % 4 == 0)
- cout << "God vusokosnui!" << endl;
- else
- cout << "God ne vusokosnui!" << endl;
- }
- void foo2(int god) {//so specufikacuey throw
- try {
- if (god < 0)
- throw 1;
- }
- catch (int) {
- cout<<"Fukcuya so specufikacuey throw!"<<endl;
- };
- if (god % 100 == 0 && god % 400 == 0)
- cout << "God vusokosnuy!" << endl;
- else if (god % 100 != 0 && god % 4 == 0)
- cout << "God vusokosnui!" << endl;
- else
- cout << "God ne vusokosnui!" << endl;
- }
- void foo3(int god) { //s konkretnoy specufikacuey s podoxodyashim standratnum isklycheniem
- try {
- if (god < 0)
- throw god;
- }
- catch (int n) {
- cout << "God ne mojet but` prinimat` znachenie "<< n << endl;
- cout<<"Isklychenie so specufikacuey s podxodyashim standartnum isklycheniem"<<endl;
- };
- if (god % 100 == 0 && god % 400 == 0)
- cout << "God vusokosnuy!" << endl;
- else if (god % 100 != 0 && god % 4 == 0)
- cout << "God vusokosnui!" << endl;
- else
- cout << "God ne vusokosnui!" << endl;
- }
- class MyEx {
- public:
- MyEx(){};
- };
- void foo4(int god) {//isklychenie pyustum klassom
- try {
- if (god < 0)
- throw MyEx();
- }
- catch (MyEx) {
- cout << "Oshubka bula zgenerirovana pystum klassom isklycheniy!" << endl;
- };
- if (god % 100 == 0 && god % 400 == 0)
- cout << "God vusokosnuy!" << endl;
- else if (god % 100 != 0 && god % 4 == 0)
- cout << "God vusokosnui!" << endl;
- else
- cout << "God ne vusokosnui!" << endl;
- }
- class MyExWithParam {
- public:
- string param;
- string returnParam(){return param;};
- MyExWithParam(string str) :
- param(str)
- {};
- };
- void foo5(int god) {
- try {
- if (god < 0)
- throw new MyExWithParam("Isklychenie s polyami-parametrami!");
- }
- catch (MyExWithParam *a) {
- cout<<a->param<<endl;
- };
- if (god % 100 == 0 && god % 400 == 0)
- cout << "God vusokosnuy!" << endl;
- else if (god % 100 != 0 && god % 4 == 0)
- cout << "God vusokosnui!" << endl;
- else
- cout << "God ne vusokosnui!" << endl;
- }
- class MyExWithParamSecond :public exception {
- };
- void foo6(int god) {
- try {
- if (god < 0)
- throw MyExWithParamSecond();
- }
- catch (MyExWithParamSecond e) {
- cout<<"Obrabotano klassom unasledovanum ot standartnogo klassa isklycheniy!"<<endl;
- cout<<e.what()<<endl;
- };
- if (god % 100 == 0 && god % 400 == 0)
- cout << "God vusokosnuy!" << endl;
- else if (god % 100 != 0 && god % 4 == 0)
- cout << "God vusokosnui!" << endl;
- else
- cout << "God ne vusokosnui!" << endl;
- }
- void main() {
- foo1(-5);
- foo2(-5);
- foo3(-5);
- foo4(-5);
- foo5(-5);
- foo6(-5);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement