#include "myString.h"
+#include <iostream>
+using std::cout;
+using std::endl;
+
+myString::myString()
+{
+ string = NULL;
+}
myString::myString(char *s)
{
setString(s);
}
+myString::myString(const myString &right)
+{
+ setString(&right);
+}
+
myString::~myString()
{
if (string)
}
else
{
+ delete []string;
+ string = new char[strlen(s) + 1];
+ memset(string, 0, (strlen(s) + 1));
+ strcpy(string, s);
+ }
+}
+void myString::setString(const char *s)
+{
+ if (!s)
+ {
+ if (string)
+ delete [] string;
+
+ string = NULL;
+ }
+ else
+ {
+ delete []string;
string = new char[strlen(s) + 1];
memset(string, 0, (strlen(s) + 1));
strcpy(string, s);
}
}
+
+void myString::setString(const myString *right)
+{
+ setString(right->string);
+}
+
+myString &myString::operator=(myString &right)
+{
+ setString(right.string);
+ return *this;
+}
+
+myString &myString::operator=(char *right)
+{
+ setString(right);
+ return *this;
+}
+
+myString &myString::operator=(const char *right)
+{
+ setString(right);
+ return *this;
+}