C++: Add = operator to String class

This commit is contained in:
Nikias Bassen
2025-04-06 11:48:14 +02:00
parent 31f1a810e5
commit ed8a73301b
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -35,6 +35,7 @@ public :
String(plist_t node, Node* parent = NULL);
String(const String& s);
String& operator=(const String& s);
String& operator=(const std::string& s);
String& operator=(const char* s);
String(const std::string& s);
String(const char *s);
+7
View File
@@ -45,6 +45,13 @@ String& String::operator=(const PList::String& s)
return *this;
}
String& String::operator=(const std::string& s)
{
plist_free(_node);
_node = plist_new_string(s.c_str());
return *this;
}
String& String::operator=(const char* s)
{
plist_free(_node);