Public Member Functions | |
string () | |
string (const char *s) | |
string (const char *s, unsigned int n) | |
string (const string &x) | |
~string () | |
string & | operator= (const char *s) |
string & | operator= (const string &x) |
const char * | c_str () const |
Data Fields | |
string::srep * | p |
Data Structures | |
struct | srep |
Definition at line 21 of file string.icc.
string::string | ( | ) | [inline] |
string::string | ( | const char * | s | ) | [inline] |
string::string | ( | const char * | s, | |
unsigned int | n | |||
) | [inline] |
string::string | ( | const string & | x | ) | [inline] |
string::~string | ( | ) | [inline] |
const char* string::c_str | ( | ) | const [inline] |
Definition at line 69 of file string.icc.
References p, and string::srep::s.
Referenced by operator+().
Definition at line 61 of file string.icc.
References string::srep::n, p, and string::srep::s.
00061 { 00062 x.p->n++; // protect against "st = st" 00063 if (--p->n == 0) { delete [] p->s; delete p; } 00064 p = x.p; 00065 return *this; 00066 }
string& string::operator= | ( | const char * | s | ) | [inline] |
Definition at line 48 of file string.icc.
References string::srep::n, p, and string::srep::s.
00048 { 00049 if (p->n > 1) { // disconnect self 00050 p->n--; 00051 p = new srep; 00052 }else{ 00053 delete [] p->s; // free old string 00054 } 00055 p->s = new char[strlen(s)+1]; 00056 strcpy(p->s, s); 00057 return *this; 00058 }
struct string::srep * string::p |
Referenced by c_str(), operator!=(), operator+(), operator<<(), operator=(), operator==(), string(), and ~string().