This project demonstrates how to build a fully functional Dynamic Array class from scratch in C++ without relying on STL containers.
The goal is not just to store data —
but to deeply understand how dynamic memory works internally and how real containers are engineered.
This class serves as a foundational building block for more advanced data structures.
- Implement a reusable Dynamic Array class using templates
- Manage heap memory manually (allocation & deallocation)
- Control resizing behavior
- Support insertion, deletion, searching, and modification
- Apply OOP design principles
- Build a scalable and extensible architecture
- Templates (Generic Programming)
- Dynamic Memory Allocation (
new/delete) - Constructors & Destructors
- Encapsulation
- Defensive Programming
- Code Reusability
- Modular Design
- Method Composition (Lego-style architecture)
This class owns its memory.
✔ When an object is created → memory is allocated dynamically
✔ When the object is destroyed → memory is released properly
✔ All operations maintain internal size integrity
✔ No STL containers are used
The design emphasizes:
- Clear responsibility
- No duplicated logic
- Reusable internal methods
- Extensibility through composition
Many high-level methods reuse core methods instead of rewriting logic.
- Initialize with specific size
SetItemGetItemSizeIsEmptyPrintListClearResize
Find(by value)
DeleteItemAt(by index)DeleteFirstItemDeleteLastItemDeleteItem(by value)
InsertAt(core insertion logic)InsertAtBeginningInsertAtEndInsertBeforeInsertAfter
All advanced methods are built on top of core logic to ensure clean architecture.
By implementing this manually, we understand:
- How arrays resize internally
- Memory reallocation strategies
- Shifting mechanics during insert/delete
- Trade-offs between arrays and linked lists
- How container abstractions are built
This shifts the mindset from:
Using data structures
to
Engineering data structures
This project follows earlier implementations using Linked Lists.
Now we explore the array-based internal model.
| Aspect | Dynamic Array | Linked List |
|---|---|---|
| Memory | Contiguous | Non-contiguous |
| Access | O(1) random access | O(n) traversal |
| Insert/Delete | Requires shifting | Pointer adjustments |
| Cache-friendly | Yes | Less |
Understanding both builds architectural awareness.
The project follows a Core + Extensions model:
- Build powerful base methods
- Reuse them to construct higher-level behavior
- Avoid duplicate logic
- Compose functionality
DeleteFirstItem()→ callsDeleteItemAt(0)DeleteItem(Value)→ usesFind()+DeleteItemAt()InsertAtBeginning()→ callsInsertAt(0, Value)
Programming is treated like assembling Lego blocks.
- C++
- Templates
- Object-Oriented Programming
- Manual Heap Memory Management
Programming Advices
https://programmingadvices.com
Dr. Mohammed Abu-Hadhoud
Programming Advices
This project is part of a structured roadmap covering:
- Data Structures & Algorithms
- OOP Mastery
- Memory Management
- Clean Code Practices
- Engineering Thinking
The focus is not memorization.
It is understanding internal mechanics and architectural reasoning.
When you understand dynamic memory…
You stop depending on ready-made containers.
You start designing your own.
And that’s the point where programming becomes engineering.