From fae6435f3c51068ece4a119fcdfc45356aab59cf Mon Sep 17 00:00:00 2001 From: Frank Filthaut Date: Tue, 10 Dec 2019 09:15:28 +0100 Subject: [PATCH] add input for ex8.3 --- ex8.3/Shape.hh | 16 ++++++++++++++++ ex8.3/Square.hh | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 ex8.3/Shape.hh create mode 100644 ex8.3/Square.hh diff --git a/ex8.3/Shape.hh b/ex8.3/Shape.hh new file mode 100644 index 0000000..fc8f92d --- /dev/null +++ b/ex8.3/Shape.hh @@ -0,0 +1,16 @@ +#ifndef SHAPE_HH +#define SHAPE_HH + +class Shape { +public: + + // Constructor, destructor + Shape() {} ; + virtual ~Shape() {} ; + + // Pure virtual interface functions + virtual double surface() const = 0 ; + virtual double circumference() const = 0 ; +} ; + +#endif diff --git a/ex8.3/Square.hh b/ex8.3/Square.hh new file mode 100644 index 0000000..fda5e54 --- /dev/null +++ b/ex8.3/Square.hh @@ -0,0 +1,23 @@ +#ifndef SQUARE_HH +#define SQUARE_HH + +#include "Shape.hh" + +class Square: public Shape { +public: + + // Constructor, destructor + Square(double size) : _size(size) {} ; + virtual ~Square() {} ; + + // Implementation of abstract interface + virtual double surface() const { return _size * _size ; } + virtual double circumference() const { return 4 * _size ; } + +private: + + double _size ; + +} ; + +#endif