Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. class Exception {
  7. protected:
  8. int code;
  9. string message;
  10. public:
  11. Exception() {
  12. int code = 0;
  13. message = "";
  14. }
  15. Exception(int code) {
  16. this->code = code;
  17. if (code == -1) {
  18. message = "Отрицательная величина массива!";
  19. }
  20. if (code == -2) {
  21. message = "NullPtr in constructor DinArr double *a";
  22. }
  23. if (code == -3) {
  24. message = "Индекс не может быть меньше 0";
  25. }
  26. if (code == -4) {
  27. message = "Индекс больше размера!";
  28. }
  29. }
  30. Exception(int code, string message) {
  31. this->code = code;
  32. this->message = message;
  33. }
  34. void what() {
  35. cout << "EXCEPTION - " << code << " MESSAGE:" << message << endl;
  36. }
  37. };
  38.  
  39. class NegativeSizeException :Exception {
  40. public:
  41. NegativeSizeException() {
  42. code = -1;
  43. message = "Отрицательная величина массива!";
  44. }
  45. };
  46.  
  47. class NullPointerException :Exception {
  48. public:
  49. NullPointerException() {
  50. code = -2;
  51. message = "NullPtr in constructor DinArr double *a!";
  52. }
  53. };
  54.  
  55. class BAD_INDEX_EXP :Exception {
  56. public:
  57. BAD_INDEX_EXP() {
  58. code = -3;
  59. message = "Индекс не может быть меньше 0";
  60. }
  61. };
  62.  
  63. class OutOfBoundException :Exception {
  64. public:
  65. OutOfBoundException() {
  66. code = -4;
  67. message = "Индекс больше размера!";
  68. }
  69. };
  70.  
  71. class VectorSizeException :Exception {
  72. public:
  73. VectorSizeException() {
  74. code = -4;
  75. message = "Разная длина векторов!";
  76. }
  77. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement