Browse Source

add input for ex8.3

master
Frank Filthaut 2 years ago
committed by Eric Teunis de Boone
parent
commit
fae6435f3c
  1. 16
      ex8.3/Shape.hh
  2. 23
      ex8.3/Square.hh

16
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

23
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