https://github.com/amrtamertech/clsstack_with_dynamic_array_library-cpp
A C++ template-based stack implementation built using a custom dynamic array class (clsDynamicArray) and extended from a custom queue structure (clsMyQueueArr). This project demonstrates how to implement a flexible stack structure with additional features such as element insertion, updating, reversing, and random access, beyond traditional LIFO beh
https://github.com/amrtamertech/clsstack_with_dynamic_array_library-cpp
cpp data-structures dynamic-array generic-programming inheritance oop stack templates
Last synced: 8 days ago
JSON representation
A C++ template-based stack implementation built using a custom dynamic array class (clsDynamicArray) and extended from a custom queue structure (clsMyQueueArr). This project demonstrates how to implement a flexible stack structure with additional features such as element insertion, updating, reversing, and random access, beyond traditional LIFO beh
- Host: GitHub
- URL: https://github.com/amrtamertech/clsstack_with_dynamic_array_library-cpp
- Owner: AmrTamerTech
- Created: 2025-06-13T12:31:45.000Z (10 days ago)
- Default Branch: main
- Last Pushed: 2025-06-13T12:57:01.000Z (10 days ago)
- Last Synced: 2025-06-13T13:44:21.512Z (10 days ago)
- Topics: cpp, data-structures, dynamic-array, generic-programming, inheritance, oop, stack, templates
- Language: C++
- Homepage:
- Size: 20.4 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ Stack Implementation (`clsMyStackArr`) โก
A C++ template-based stack implementation built on top of a dynamic array-based queue (`clsMyQueueArr`). This class simulates LIFO (Last In, First Out) behavior using `clsDynamicArray`. ๐
---
## ๐ Project Overview
The `clsMyStackArr` class extends the `clsMyQueueArr` class and adapts its behavior to act as a **stack**. By overriding the `Push()` function to insert elements at the front of the dynamic array, it enables typical stack operations like `Push`, `Top`, and `Bottom`, while maintaining access to other dynamic features.
This implementation uses **C++ templates**, making it type-generic and suitable for any data type.
---
## ๐น Core Functionalities:
- ๐ Push: Insert elements in LIFO order
- ๐ Top & Bottom: Access the first and last items
- ๐ Stack Size, Print, and Clear
- ๐ Reverse and Modify Internal Elements (Inherited)
- โจ All the power of `clsMyQueueArr` + stack-specific control---
## โจ Features
### ๐น Stack-Specific Operations
- `Push(Value)` โ Adds an element to the **top** (front) of the stack.
- `Top()` โ Returns the **top** element of the stack.
- `Bottom()` โ Returns the **bottom** element of the stack (oldest pushed).### ๐น Inherited Functionalities from `clsMyQueueArr`
- `Pop()` โ Removes the top (front) element.
- `Size()` โ Returns number of elements.
- `IsEmpty()` โ Checks if stack is empty.
- `Print()` โ Displays all stack elements.
- `Reverse()` โ Reverses stack order.
- `GetItem(Index)`, `UpdateItem(Index, NewValue)`
- `InsertAfter(Index, Value)`, `InsertAtBack(Value)`
- `Clear()` โ Empties the stack completely.---
## ๐ How It Works
### ๐น LIFO Behavior
- `Push()` inserts at the **beginning** of the internal array.
- `Pop()` removes from the **beginning** (top of stack).### ๐น Element Access
- `Top()` = first element = most recently pushed.
- `Bottom()` = last element = earliest pushed.---
## โ๏ธ Technologies Used
- **Language**: C++
- **Templates**: Enables generic stack support
- **Inheritance**: Leverages `clsMyQueueArr`
- **Dynamic Array**: Efficient memory use via `clsDynamicArray`---
## ๐ฏ Learning Outcomes
โ Understanding of stack behavior using arrays
โ C++ templates and inheritance
โ Custom dynamic data structures
โ Using queue logic to implement a stack---
## ๐ License
This project is open-source. Feel free to use and extend it! ๐
---
## ๐ค Contributing
Contributions and ideas are welcome. Fork the project, enhance it, and open a pull request!
---
## ๐ How to Run
1. ๐ฅ Clone the repository:
```bash
git clone https://github.com/your-username/clsStack_With_Dynamic_Array_Library-CPP.git
cd clsMyStackArr-CPP
```
2. ๐ Include in your project:
```bash#include"clsMyQueueArr.h"
#include"clsDynamicArray.h"
#invlude"clsMyStackArr.h"
```
3. ๐งช Compile and run using a C++ compiler:```bash
g++ main.cpp -o app
./app
```