โ— Shell
clean mode source โ†—

GitHub - ZohaibCodez/text-string-clone: A custom C++ implementation of the std::string class with full memory management, operator overloading, and OOP design principles

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.


๐Ÿ“š Table of Contents


๐Ÿ”ง Features

  • 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(), and substr() methods
  • Operator overloading: +, +=, [], =
  • Stream I/O with cin and cout
  • Exception-safe operations

๐Ÿ“ Project Structure


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!

๐Ÿš€ Getting Started

๐Ÿ”จ Build the Project

make         # Builds the project
make run     # Runs the demo
make clean   # Cleans build files

๐Ÿงช Example Usage

#include "text.h"

int main() {
    text t1 = "Hello";
    text t2 = "World";
    text t3 = t1 + " " + t2;
    std::cout << "t3: " << t3 << std::endl;
}

๐Ÿ“Œ Sample Output

t1: Hello
t2:  World
t3 (t1 + t2): Hello World
Length of t3: 11
Capacity of t3: 12
...

๐Ÿ“š Skills Demonstrated

  • Object-Oriented Programming (OOP)
  • Rule of Five in C++
  • Operator Overloading
  • Exception handling
  • Manual Memory Management
  • Header and Source File Separation

๐Ÿ’ก Why This Project?

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.


๐Ÿง‘โ€๐Ÿ’ป Author

Mr. Zohaib ๐Ÿ”— LinkedIn


๐Ÿ“œ License

This project is licensed under the MIT License.