diff options
Autocommit at 08.05.2022 @ 10:08
2 files changed, 13 insertions, 0 deletions
| -rw-r--r-- | src/Generic/String/String.cpp | 12 | ||||
| -rw-r--r-- | src/Generic/String/String.h | 1 |
diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index bacd72c..251ba0a 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -48,6 +48,18 @@ String& String::operator+=(const char* str) { return *this; } +String& String::operator+=(unsigned number) { + unsigned tempLen = number / 10 + 1; + char* tmp = new char[tempLen + 1]; + tmp[tempLen] = '\0'; + for (unsigned i = tempLen - 1; i >= 0; i--, number /= 10) + tmp[i] = number % 10 + '0'; + + *this += tmp; + delete[] tmp; + return *this; +} + String::String() : String("") {} String::String(const String& other) { diff --git a/src/Generic/String/String.h b/src/Generic/String/String.h index 6217e0a..6a8b014 100644 --- a/src/Generic/String/String.h +++ b/src/Generic/String/String.h @@ -18,6 +18,7 @@ public: unsigned get_length() const; String& operator+=(const char* str); + String& operator+=(unsigned number); String(); String(const String& other); |
