CString::operator +

friend CString operator +( const CString& string1, const CString& string2 );
throw( CMemoryException );

friend CString operator +( const CString& string, TCHAR ch );
throw( CMemoryException );

friend CString operator +( TCHAR ch, const CString& string );
throw( CMemoryException );

friend CString operator +( const CString& string, LPCTSTR lpsz );
throw( CMemoryException );

friend CString operator +( LPCTSTR lpsz, const CString& string );
throw( CMemoryException );

Return Value

A CString object that is the temporary result of the concatenation. This return value makes it possible to combine several concatenations in the same expression.

Parameters

string, string1, string2

CString objects to concatenate.

ch

A character to concatenate to a string or to concatenate a string to.

lpsz

A pointer to a null-terminated character string.

Remarks

The + concatenation operator joins two strings and returns a CString object. One of the two argument strings must be a CString object. The other can be a character pointer or a character. You should be aware that memory exceptions may occur whenever you use the concatenation operator since new storage may be allocated to hold temporary data.

Example

The following example demonstrates the use of CString::operator +.

// example for CString::operator +
CString s1( "abc" );
CString s2( "def" );
ASSERT( (s1 + s2 ) == "abcdef" );
CString s3;
s3 = CString( "abc" ) + "def" ; // Correct
s3 = "abc" + "def"; 
// Wrong! The first argument must be a CString.

CString OverviewClass MembersHierarchy Chart

See Also   CString::operator +=