yo/concrete/poly/base/base.h
raw| 1 | #ifndef INCLUDED_BASE_ |
| 2 | #define INCLUDED_BASE_ |
| 3 | |
| 4 | #include <iosfwd> |
| 5 | |
| 6 | class Base |
| 7 | { |
| 8 | friend std::ostream &operator<<(std::ostream &out, Base const &obj); |
| 9 | |
| 10 | public: |
| 11 | virtual ~Base() = default; |
| 12 | Base *clone() const; |
| 13 | private: |
| 14 | virtual Base *ownClone() const = 0; |
| 15 | virtual std::ostream &insert(std::ostream &os) const = 0; |
| 16 | }; |
| 17 | |
| 18 | inline std::ostream &operator<<(std::ostream &out, Base const &obj) |
| 19 | { |
| 20 | return obj.insert(out); |
| 21 | } |
| 22 | |
| 23 | #endif |