CStringT::operator +
Concatenates two strings or a character and a string.
friend CStringT operator+(
const CStringT& str1,
const CStringT& str2
);
friend CStringT operator+(
const CStringT& str1,
PCXSTR psz2
);
friend CStringT operator+(
PCXSTR psz1
const CStringT& str2,
);
friend CStringT operator+(
char ch1
const CStringT& str2,
);
friend CStringT operator+(
const CStringT& str1,
char ch2
);
friend CStringT operator+(
const CStringT& str1,
wchar_t ch2
);
friend CStringT operator+(
wchar_t ch1
const CStringT& str2,
);
Parameters
ch1
An ANSI or Unicode character to concatenate with a string.ch2
An ANSI or Unicode character to concatenate with a string.str1
A CStringT to concatenate with a string or character.str2
A CStringT to concatenate with a string or character.psz1
A pointer to a null-terminated string to concatenate with a string or character.psz2
A pointer to a string to concatenate with a string or character.
Remarks
There are seven overload forms of the CStringT::operator+ function. The first version concatenates two existing CStringT objects. The next two concatenate a CStringT object and a null-terminated string. The next two concatenate a CStringT object and an ANSI character. The last two concatenate a CStringT object and a Unicode character.
Notes
Although it is possible to create CStringT instances that contain embedded null characters, we recommend against it. Calling methods and operators on CStringT objects that contain embedded null characters can produce unintended results.
Example
// typedef CStringT<TCHAR, StrTraitATL<TCHAR, ChTraitsCRT<TCHAR>>> CAtlString;
CAtlString s1(_T("dog ")), s2(_T(" awake")), s3; // Empty CAtlString objects
s1= _T("The ") + s1;
s3= s1 + _T('i');
s3= s3 + _T('s');
s3= s3 + s2;
ASSERT(s3 == _T("The dog is awake"));
Requirements
Header: cstringt.h