Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdexcept>
- #include <string>
- #include <cmath>
- #include <limits>
- using namespace std;
- void my_unexpected()
- {
- cout<<"был вызван unexpected"<<endl;
- exit(0);
- }
- void my_terminate()
- {
- cout<<"был вызван terminate"<<endl;
- exit(0);
- }
- class MyException0 : public exception
- {
- public:
- MyException0():exception(){}
- };
- class MyException1 : public invalid_argument
- {
- public:
- MyException1(const string& error_msg):invalid_argument(error_msg){}
- };
- class MyException2 : public runtime_error
- {
- public:
- MyException2(const string& error_msg):runtime_error(error_msg){}
- };
- class Vector0
- {
- private:
- int x;
- int y;
- int z;
- void Init(int x, int y, int z)
- {
- this->x = x;
- this->y = y;
- this->z = z;
- }
- public:
- Vector0(int x=0, int y=0, int z=0) throw(invalid_argument, bad_exception)
- try
- {
- cout<<x<<endl;
- if(abs(x)>numeric_limits<int>::max() || abs(y)>numeric_limits<int>::max() || abs(z)>numeric_limits<int>::max())
- throw invalid_argument("слишком большое или маленькое значение координат");
- this->x = x;
- this->y = y;
- this->z = z;
- }
- catch(const invalid_argument& error)
- {
- cout<<error.what()<<endl;
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- set_terminate(my_terminate);
- set_unexpected(my_unexpected);
- try
- {
- Vector0 a(31231231233131231,12,23);
- cout<<numeric_limits<int>::min()<<endl;
- }
- catch(const exception& error)
- {
- cout<<error.what()<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment