Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <string>
- #include <iostream>
- using namespace std;
- class Exception {
- protected:
- int code;
- string message;
- public:
- Exception() {
- int code = 0;
- message = "";
- }
- Exception(int code) {
- this->code = code;
- if (code == -1) {
- message = "Отрицательная величина массива!";
- }
- if (code == -2) {
- message = "NullPtr in constructor DinArr double *a";
- }
- if (code == -3) {
- message = "Индекс не может быть меньше 0";
- }
- if (code == -4) {
- message = "Индекс больше размера!";
- }
- }
- Exception(int code, string message) {
- this->code = code;
- this->message = message;
- }
- void what() {
- cout << "EXCEPTION - " << code << " MESSAGE:" << message << endl;
- }
- };
- class NegativeSizeException :Exception {
- public:
- NegativeSizeException() {
- code = -1;
- message = "Отрицательная величина массива!";
- }
- };
- class NullPointerException :Exception {
- public:
- NullPointerException() {
- code = -2;
- message = "NullPtr in constructor DinArr double *a!";
- }
- };
- class BAD_INDEX_EXP :Exception {
- public:
- BAD_INDEX_EXP() {
- code = -3;
- message = "Индекс не может быть меньше 0";
- }
- };
- class OutOfBoundException :Exception {
- public:
- OutOfBoundException() {
- code = -4;
- message = "Индекс больше размера!";
- }
- };
- class VectorSizeException :Exception {
- public:
- VectorSizeException() {
- code = -4;
- message = "Разная длина векторов!";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement