str!=NULL为何会出错
bool check(string str)
{
if(str!=NULL)
..........
}
这是我程序里一部分
if(str!=NULL)这条语句总是报错,不知什么原因,原来可以用的
错误信息是:error C2678: binary '!=' : no operator defined which takes a left-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
求高手看下什么原因
[解决办法]
string又不是指针,最好不要这样用吧,试试用empty成员函数
[解决办法]
没有定义的“class std::basic_string”类型的左操作运算符(或者没有定义的可接受转换)
没这样用过
可以用if(str.Empty())
或者if(0 == str.Length())