术语 | CString::operator + | ||||||
释义 | 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 ); 返回值: 返回一个CString对象,该对象是此连接操作的临时结果。这个返回值使得在一个表达式中组合多次连接成为可能。 参数:
说明: 此+操作符将两个字符串连接起来并返回一个CString对象。两个参数中的一个必须是一个CString对象,而另一个可以是指向字符的指针或是一个字符。不管你什么时候使用这个连接操作符,都要小心可能出现的内存异常,因为为了保存这个临时结果常常要分配新内存。 示例: 下面的例子说明了如何使用CString::operator +。 // CString::operator +示例: CString s1( "abc" ); CString s2( "def" ); ASSERT( (s1 + s2 ) == "abcdef" ); CString s3; s3 = CString( "abc" ) + "def"; // Correct s3 = "abc" + "def"; // 错了!第一个参数必须是一个CString。 请参阅:CString::operator += |
||||||
随便看 |
|
MFC类库中文详解手册包含4274条MFC类库参考词条,基本涵盖了Microsoft基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。