p->n = 1;
}
+String::String(const std::string &x)
+{
+ p = new srep;
+
+ p->n = 1;
+ p->s = new char[x.size()+1];
+ x.copy(p->s, x.size());
+
+}
+
String::~String()
{
if (--p->n == 0)
return *this;
}
+String& String::operator=(const std::string &x)
+{
+ if (p->n > 1)
+ { // Disconnect self
+ p->n--;
+ p = new srep;
+ }
+ else if (p->n == 1)
+ delete p->s;
+
+ p->n = 1;
+ p->s = new char[x.size()+1];
+ x.copy(p->s, x.size());
+
+ return *this;
+}
+
/* Numerical conversion */
String::String(int i)