【发布时间】:2013-09-03 16:44:40
【问题描述】:
我在我的 MFC DOC/VIEW 应用程序中遇到了一些带有转换 LPCTSTR 参数 (szNewChr) 的错误,错误:错误 C2664: 'int ATL::CStringT::Find(wchar_t,int) throw() const' : cannot convert参数 1 从 'const char [2]' 到 'wchar_t', 在 atof 方法中,出现错误:错误 C2664: 'atof' : cannot convert parameter 1 from 'CString' to 'const char *'
这是我的方法:
void CmojaView::UpdateResultsWnd(LPCTSTR szNewChr)
{
// Ensure we are not trying to add a second decimal point!
if(szNewChr == "." && m_strCurrentEntry.Find(".") != -1)
return;
// Update the private member variables
m_strCurrentEntry+=szNewChr;
CString strCurrentEntry(m_strCurrentEntry);
strCurrentEntry.Remove('*');
strCurrentEntry.Remove('/');
m_fResultsWndValue=atof(strCurrentEntry);
m_nClearBtnStatus=0;
}
这些是 .h 文件中定义的数据成员:
CString m_strCurrentEntry;
double m_fResultsWndValue;
double m_fRunningTotal;
char m_cLastOp;
int m_nClearBtnStatus;
double m_fMemory;
UINT m_nLastKey;
我想注意到它可以完美地作为基于对话框的应用程序... 提前致谢。
【问题讨论】:
-
见this。它解决了同样的问题。
标签: mfc