< Previous | Contents | Next >
The empty() member function returns a bool value—true if the string object is empty and false otherwise. I use empty() in the following code:
if (phrase.empty())
{
cout << "\nThe phrase is no more.\n";
}
Because phrase is equal to the empty string, phrase().empty returns true, and the screen displays the message, “The phrase is no more.”