#include<iostream>
using namespace std;
#include<string>
int main()
{
string a;
string b;
a = "asdfgg";
b = "";
cout << "a是否为空:" << a.empty() << endl;
cout << "b是否为空:" << b.empty() << endl;
system("pause");
return 0;
}
运行结果:
若是空的,则返回0,若不是空的,则返回1。