Guest User

Untitled

a guest
Nov 25th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #ifndef TRANSFORMMATRIX_H
  2. #define TRANSFORMMATRIX_H
  3. #include "matrix.h"
  4. #include "math.h"
  5.  
  6. class BaseTransformMatrix : public Matrix<double>
  7. {
  8. public:
  9. BaseTransformMatrix();
  10. };
  11.  
  12. class MoveMatrix : public BaseTransformMatrix
  13. {
  14. public:
  15. MoveMatrix(double x, double y, double z);
  16. };
  17.  
  18. #endif // TRANSFORMMATRIX_H
  19.  
  20. #ifndef MATRIX_H
  21. #define MATRIX_H
  22. #include "vector.h"
  23. #include "base_matrix.h"
  24.  
  25. template <typename T>
  26. class Matrix : public BaseMatrix
  27. {
  28. public:
  29. Matrix();
  30. Matrix(int m, int n);
  31. ... // Other methods and fields
  32.  
  33. private:
  34. Vector<Vector<T>> matr;
  35. };
  36.  
  37. #include "matrix.cpp" // Файл реализации с методами
  38. #endif // MATRIX_H
  39.  
  40. #ifndef BASE_MATRIX_H
  41. #define BASE_MATRIX_H
  42.  
  43. class BaseMatrix
  44. {
  45. protected:
  46. int m;
  47. int n;
  48.  
  49. public:
  50. BaseMatrix();
  51. BaseMatrix(int m, int n);
  52. BaseMatrix(const BaseMatrix &matrix) = delete;
  53.  
  54. virtual ~BaseMatrix() {}
  55.  
  56. int length_m() const;
  57. int length_n() const;
  58. bool isEmpty() const;
  59. };
  60.  
  61. #include "base_matrix.cpp" // Опять же файл реализации
  62.  
  63. #endif // BASE_MATRIX_H
  64.  
  65. #ifndef BASE_MATRIX_CPP
  66. #define BASE_MATRIX_CPP
  67. #include "base_matrix.h"
  68.  
  69. BaseMatrix::BaseMatrix():m(0), n(0) {}
  70.  
  71. BaseMatrix::BaseMatrix(int m, int n):m(m), n(n) {}
  72.  
  73. int BaseMatrix::length_m() const
  74. {
  75. return this->m;
  76. }
  77.  
  78. int BaseMatrix::length_n() const
  79. {
  80. return this->n;
  81. }
  82.  
  83. bool BaseMatrix::isEmpty() const
  84. {
  85. if (this->m && this->n)
  86. return false;
  87. else
  88. return true;
  89. }
  90.  
  91. #endif // BASE_MATRIX_CPP
  92.  
  93. ...myTestbase_matrix.cpp:11: ошибка: multiple definition of `BaseMatrix::length_m() const'
  94. ...myTestbase_matrix.cpp:11: first defined here ...myTestbase_matrix.cpp
  95. ...myTestbase_matrix.cpp:17: ошибка: multiple definition of `BaseMatrix::length_n() const'
  96. ...
  97.  
  98. int main(){}
Add Comment
Please, Sign In to add comment