/
dolpement
/
OOP
Обзор
Документация
Войти
/
dolpement
/
OOP
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
stack_base_prj/stack_base/stack_base.hpp
46 строк
1 KB
dolpement
OOP
16 июл 2025, 15:40
16 июл 2025, 15:40
d149512
Код
Авторство
О чём код?
#ifndef ISTACKBASE_HPP #define ISTACKBASE_HPP #include <initializer_list> #include <stdexcept> #include <utility> #include <cstddef> #include <ostream> template <typename T> class IStackBase { public: using value_type = T; virtual ~IStackBase() = default; // Чисто виртуальные методы virtual void push(const T& value) = 0; virtual void pop() = 0; virtual T& top() const = 0; virtual void swap(IStackBase<T>& other) = 0; virtual void merge(IStackBase<T>& other) = 0; virtual bool empty() const = 0; virtual std::ptrdiff_t size() const = 0; virtual bool operator==(const IStackBase<T>& rhs) const = 0; virtual bool operator!=(const IStackBase<T>& rhs) const = 0; virtual void printToStream(std::ostream& os) const = 0; protected: IStackBase() = default; IStackBase(const IStackBase&) = default; IStackBase(IStackBase&&) = default; IStackBase& operator=(const IStackBase&) = default; IStackBase& operator=(IStackBase&&) = default; }; template <typename T> std::ostream& operator<<(std::ostream& os, const IStackBase<T>& stack) { stack.printToStream(os); return os; } #endif // ISTACKBASE_HPP