最近排查一个问题, 逻辑刚好相反, 查出是一个empty函数的误用, 来看看代码:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s = "abc";
if(s.empty)
{
cout << "yes" << endl;
}
else
{
cout << "no" << endl;
}
return 0;
}
呵呵哒, empty后面的额()漏掉了, 于是逻辑就完全反了, 以后大家都注意一下吧。