【发布时间】:2017-01-15 06:30:32
【问题描述】:
也许任何人都可以向我解释:
bool Func1(LPCTSTR sData)
{
if (sData) { ... }
}
我这样调用函数:
CString str = _T("");
Func1((str.IsEmpty() ? NULL : str));
而且函数内部的'sData'永远不会为NULL,它总是空字符串但不是NULL,为什么? 修改后的代码如下:
LPCTSTR strNull = NULL;
Func1((str.IsEmpty() ? strNull : str));
在这种情况下它工作正常。
【问题讨论】:
-
Func1((str.IsEmpty() ? NULL : str));在 VS2015 上无法编译,我得到Error C2446 ':': no conversion from 'CString' to 'int' ...