Added copy assignment operator to string.

This commit is contained in:
Relintai 2021-11-01 01:02:18 +01:00
parent 37ae4faa29
commit 3ae9ae5127
2 changed files with 11 additions and 0 deletions

View File

@ -604,6 +604,14 @@ bool operator!=(std::string &b, const String &a) {
return !(a == b);
}
String& String::operator=(const String &other) {
clear();
append_str(other);
return *this;
}
String::String() {
_data = nullptr;
_actual_size = 0;
@ -695,5 +703,6 @@ String::String(const std::string &str) {
String::~String() {
if (_data) {
delete[] _data;
_data = nullptr;
}
}

View File

@ -97,6 +97,8 @@ public:
operator std::string() { return to_string(); }
operator std::string() const { return to_string(); }
String& operator=(const String &other);
String();
String(const String &other);
String(const String &other, const int grow_by);