diff options
author | Nao Pross <naopross@thearcway.org> | 2018-12-08 12:58:04 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-12-08 12:58:04 +0100 |
commit | 05f2df34290af477b0fee49b75e5f56e1d6c83f9 (patch) | |
tree | 66a7214321c874be02d1a4a9b4fd3f489dc09ad8 /inheritance.hpp | |
download | cplusplus-05f2df34290af477b0fee49b75e5f56e1d6c83f9.tar.gz cplusplus-05f2df34290af477b0fee49b75e5f56e1d6c83f9.zip |
Initial commit with kinda crappy unnumbered examples
Diffstat (limited to '')
-rw-r--r-- | inheritance.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/inheritance.hpp b/inheritance.hpp new file mode 100644 index 0000000..6fbc48e --- /dev/null +++ b/inheritance.hpp @@ -0,0 +1,40 @@ +#include <cstddef> + +class container { +public: + const std::size_t max_size; + + container() = delete; + container(std::size_t max_size); + virtual ~container(); + + virtual void add(int v) = 0; + virtual int get() = 0; + +protected: + int *m_storage = nullptr; +}; + + +class lifo : public container { +public: + lifo(std::size_t max_size) : container(max_size) {} + + void add(int v) override; + int get() override; + + void push(int v); + int pop(); + +private: + unsigned m_top = 0; +}; + + +class fifo : public container { + fifo(std::size_t max_size) : container(max_size) {} + + void add(int v) override; + int get() override; +}; + |