Advertisement
Guest User

help help

a guest
Apr 7th, 2020
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. geometricalObject.h:
  2. #pragma once
  3. class GeometricalObject
  4. {
  5. public:
  6.     double Length = 0;
  7.     double SurfaceArea = 0;
  8.  
  9. protected:
  10.     virtual double GetSurfaceArea();
  11. };
  12.  
  13. Square.h:
  14. #pragma once
  15. #include "GeometricalObject.h"
  16. class Square :
  17.     public GeometricalObject
  18. {
  19. public:
  20.     Square(double length);
  21.  
  22.     double GetLength();
  23.     void SetLength(double value);
  24.  
  25.     double GetSurfaceArea() override;
  26.  
  27. };
  28.  
  29. Square.cpp:
  30. #include "Square.h"
  31.  
  32.  
  33. Square::Square(double length)
  34. {
  35.     this->Length = length;
  36.     this->SurfaceArea = GetSurfaceArea();
  37. }
  38.  
  39. double GetLength()
  40. {
  41.     return Length;
  42. }
  43.  
  44. void SetLength(double value)
  45. {
  46.     if (value >= 0)
  47.     {
  48.         GeometricalObject::Length = value;
  49.     }
  50. }
  51.  
  52. double GetSurfaceArea()
  53. {
  54.     return this->Length * this->Length;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement