Skip to main content
1 of 2
Toby Speight
  • 88.4k
  • 14
  • 104
  • 327

You do need to include <string>. Your platform seems to bring it in as a side-effect of other includes, but you can't portably rely on that.

If there's no need to modify the contents of the string, prefer to pass by reference, to reduce copying:

bool string_contains_integer(const std::string& str)
//                           ^^^^^            ^

Instead of looping with indexes, learn to use iterators. If you really must use indexes, use the correct type (std::string::size_type, not unsigned long long).

Toby Speight
  • 88.4k
  • 14
  • 104
  • 327