Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Stack Implementation

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.


✨ What’s inside?

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}

📝 Customising

  • Element type – change int to a template parameter to store any POD or class.
  • Growth strategy – replace full reallocation with exponential resizing (reserve/capacity) for O(1) amortised push.
  • Safety – add rule‑of‑five, move semantics, or throw exceptions instead of returning NULL in top().

⚖️ License

MIT — free to use, learn from, and extend.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages