I am reading a C++ Book C++ Primer 5th Edition in chapter 4 there is a code block
for (const auto &s : text)
{
cout << s << " " << typeid(s).name() << " ";
if (s.empty() || s[s.size() - 1] == '.')
cout << endl;
else
cout << " "; // otherwise just separate with a space
}
When i run this code and using text string it is give me an error and the same when i use char*
`op.cpp:65:9: error: request for member 'empty' in 's', which is of non-class type 'const char'
Aucun commentaire:
Enregistrer un commentaire