A minimal header‑only stack library written in modern C++ that manages its own dynamic array, supports push, pop, top, and isEmpty, and stores items as lightweight StackElement objects.
| File / Class | Purpose |
|---|---|
Stack.h / Stack.cpp |
Dynamic stack that reallocates (new[], copy, delete[]) on push/pop. Includes top() and emptiness check. :contentReference[oaicite:0]{index=0} |
StackElement.h / .cpp |
Small wrapper holding value + index, with copy‑constructor and accessors. :contentReference[oaicite:1]{index=1} |
- Element type – change
intto a template parameter to store any POD or class. - Growth strategy – replace full reallocation with exponential resizing (
reserve/capacity) for O(1) amortisedpush. - Safety – add rule‑of‑five, move semantics, or throw exceptions instead of returning
NULLintop().
MIT — free to use, learn from, and extend.