Skip to main content

Practice · 1 of 1

Class template: Stack<T>

CHALLENGE
Difficulty: intermediate+25 XP

Implement template <typename T> class Stack backed by std::vector<T> with: void push(T), T pop() (removes and returns the top — moving, not copying), const T& top() const, bool empty() const, std::size_t size() const. It must instantiate for int and std::string.

Back to lesson: Practice: Class template practice