Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A custom C++ implementation of the std::string class with full memory management, operator overloading, and OOP design principles

License

Notifications You must be signed in to change notification settings

ZohaibCodez/text-string-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

πŸ“¦ Custom C++ String Class β€” text

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.

About

A custom C++ implementation of the std::string class with full memory management, operator overloading, and OOP design principles

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /