SVN / public / code / vorlesung-10 / Thing.h

Revision 11340
Date
Committerhb1003
Download
// Copyright 2016, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Hannah Bast <bast@cs.uni-freiburg.de>.

#ifndef VORLESUNG_10_THING_H_
#define VORLESUNG_10_THING_H_

#include <string>

// Simple class which only knows how to convert itself to a string.
class Thing {
 public:
  virtual std::string toString();
  virtual ~Thing();
};

// Subclass IntegerThing holding an integer.
class IntegerThing : public Thing {
 public:
  // Constructor.
  explicit IntegerThing(int value);

  // Destructor.
  ~IntegerThing();

  // Overwrite toString method inherited from Thing.
  std::string toString();

 private:
  int* _value;
};

// Subclass StringThing holding a string.
class StringThing : public Thing {
 public:
  // Constructor.
  explicit StringThing(std::string contents);

  // Overwrite toString method inherited from Thing.
  std::string toString();

 private:
  std::string _contents;
};

#endif  // VORLESUNG_10_THING_H_