diff options
1 files changed, 48 insertions, 0 deletions
| -rw-r--r-- | Sem. 15/MyString/MyString.h | 48 |
diff --git a/Sem. 15/MyString/MyString.h b/Sem. 15/MyString/MyString.h new file mode 100644 index 0000000..b6d7c13 --- /dev/null +++ b/Sem. 15/MyString/MyString.h @@ -0,0 +1,48 @@ +#pragma once +#include <iostream> +#include <fstream> +class MyString +{ + char* str; + size_t size; + + void copyFrom(const MyString& other); + void free(); + + void concatFrom(const MyString& other); + +public: + MyString(); + MyString(const char*); + MyString(size_t n); //convert constructor + + MyString(const MyString&); + + MyString(MyString&&); //move constructor that accepts rvalue; + + MyString& operator=(const MyString& other); + MyString& operator=(MyString&& other); //move op= that accepts rvalue; + + const char& operator[](size_t index) const; + char& operator[](size_t index); + + ~MyString(); + + size_t getSize() const; + + const char* c_str() const; + + MyString& operator+=(const MyString& other); + + friend std::ostream& operator<<(std::ostream& stream, const MyString& str); + friend std::istream& operator>>(std::istream& stream, MyString& str); + + MyString subString(size_t start, size_t end) const; + +}; + +MyString operator+(const MyString& lhs, const MyString& rhs); + +bool operator==(const MyString& lhs, const MyString& rhs); +bool operator<=(const MyString& lhs, const MyString& rhs); +bool operator<(const MyString& lhs, const MyString& rhs); |
