string s1 ("This is a");
string s2 = s1 + "test!";
//s2 -> "’this is a test!"
string s3 = s2 +s1;
String String::operator + (char* szStr)
{
int nSize = n_nLength + strlen(szStr);
char* ptemp = new char [nSize +1] ;
if (n_szData !=NULL
{
strcpy (ptemp, n_szData);
}
if(szStr !=Null)
{
strcpy (ptemp + m_nlength, sz Str);
}
//character array that is a concatenation of two strings
string ret(ptemp);
delete [ ] pTemp;
return ret;
}
string string:: operator +(Stirng & s)
{
int nSize = n_nLength + s. m_nLength;
char* pTemp = now char [nSize +1];
if (m_nLength !=0)
{
strcpy(pTemp, m_szData);
{
if(s.n_nLength !=)
{
strcpy(ptemp + n_nLength, s. n_szData);
}
String ret(pTemp);
delete[ ]pTemp;
return ret,
}