在VS2005环境,建立的MFC工程。定义了一个CString 对象m_strInputLine
在消息处理函数
void CTextView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
m_strInputLine += nChar;
}
编译时出错
说重载操作符出错,提示信息:error C2593: “operator +=”不明确
解答如下:
CString,在vs2008中,为unicode,wchar_t基类型。
而CString,在vc6.0中为ansi,char基类型。
所以在vs2008:
m_strInputLine是wchar_t。
应将UINT nChar转换成wchar_t。