diff options
Autocommit at 08.05.2022 @ 09:53
2 files changed, 12 insertions, 0 deletions
| -rw-r--r-- | src/Generic/Date/Date.h | 3 | ||||
| -rw-r--r-- | src/Generic/String/String.cpp | 9 |
diff --git a/src/Generic/Date/Date.h b/src/Generic/Date/Date.h index a7c0ecb..a960678 100644 --- a/src/Generic/Date/Date.h +++ b/src/Generic/Date/Date.h @@ -3,6 +3,7 @@ #include <istream> #include <ostream> +#include "../String/String.h" class Date { unsigned short day; @@ -24,6 +25,8 @@ public: unsigned short get_year() const; bool set_year(unsigned short year); + String createCStr(); + void read(std::istream& istr); void write(std::ostream& ostr); int compare(const Date& other) const; diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp index 4de5a29..bacd72c 100644 --- a/src/Generic/String/String.cpp +++ b/src/Generic/String/String.cpp @@ -36,6 +36,15 @@ unsigned String::get_length() const { } String& String::operator+=(const char* str) { + unsigned strLen = strlen(str); + char* newStr = new char[length + strLen + 1]; + strncpy(newStr, this->str, length + 1); + strncat(newStr, str, strLen + 1); + + delete[] this->str; + this->str = newStr; + length += strLen; + return *this; } |
