如何串联CComBSTR
和串接?
我已经尝试过这种方式:
CComBSTR a = "DEF";
CComBSTR strRequete = "ABC'" + a + "GHI"; //marked line
但是我a
在marked line
讲一个错误:
错误:表达式必须具有整数或无作用域的枚举类型。
非常感谢!
要串联,您有8种方法:
HRESULT Append(LPCOLESTR lpsz, int nLen);
HRESULT Append(LPCOLESTR lpsz);
HRESULT Append(LPCSTR);
HRESULT Append(char ch);
HRESULT Append(wchar_t ch);
HRESULT Append(const CComBSTR& bstrSrc);
CComBSTR& operator+=(const CComBSTR& bstrSrc);
HRESULT AppendBSTR(BSTR p);
使用+ =运算符,您可以像这样追加:
CComBSTR strSentence = OLESTR("Now is the time ");
// strSentence contains "Now is the time "
CComBSTR str11 (OLESTR("for all good men ");
// calls Append(const CComBSTR& bstrSrc);
strSentence.Append(str11);
// strSentence contains "Now is the time for all good men "
// calls Append(LPCOLESTR lpsz);
strSentence.Append((OLESTR("to come "));
// strSentence contains "Now is the time for all good men to come "
// calls Append(LPCSTR lpsz);
strSentence.Append("to the aid ");
// strSentence contains
// "Now is the time for all good men to come to the aid "
CComBSTR str12 (OLESTR("of their country"));
strSentence += str12; // calls operator+=()
// "Now is the time for all good men to come to
// the aid of their country"
在此链接上可以找到更多类似的信息:http : //www.369o.com/data/books/atl/0321159624/ch02lev1sec3.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句