A lightweight and educational reimplementation of the C++ std::string class for learning purposes. Built from scratch using only core C++ features β no STL string backend.
- Features
- Project Structure
- Getting Started
- Sample Output
- Skills Demonstrated
- Why This Project?
- Author
- License
- Manual dynamic memory management (
new/delete) - Deep copy and move semantics (Rule of Five)
- Initializer list support
- Substring, insert, erase, replace, and append
- Comparison operators:
==,!=,<,>,<=,>= - Safe
at(),find(), andsubstr()methods - Operator overloading:
+,+=,[],= - Stream I/O with
cinandcout - Exception-safe operations
TextCloneProject/
βββ include/ # Header files
β βββ text.h
βββ src/ # Class implementation
β βββ text.cpp
βββ tests/ # Usage examples
β βββ main.cpp
βββ bin/ # Output binaries
βββ Makefile # For build automation
βββ README.md # You're reading it!
make # Builds the project make run # Runs the demo make clean # Cleans build files
#include "text.h" int main() { text t1 = "Hello"; text t2 = "World"; text t3 = t1 + " " + t2; std::cout << "t3: " << t3 << std::endl; }
t1: Hello
t2: World
t3 (t1 + t2): Hello World
Length of t3: 11
Capacity of t3: 12
...
- Object-Oriented Programming (OOP)
- Rule of Five in C++
- Operator Overloading
- Exception handling
- Manual Memory Management
- Header and Source File Separation
This project is part of my second-semester coursework at PUCIT, developed to master advanced C++ concepts like dynamic memory, object lifecycles, and class design without relying on the Standard Library string class.
Mr. Zohaib π LinkedIn
This project is licensed under the MIT License.