Plain arrays don't have methods, so you can't call begin()
and end()
on them. But you can use the non-member functions of the same name:
#include <alorithm> // for std::find
#include <iterator> // for std::begin, std::end
bool isKeyword(string s)
{
std::find(std::begin(keywords), std::end(keywords), s ) != std::end(keywords);
}
If you don't have C++11 support, you can easily roll these functions out yourself, or use the size of the array to get the end iterator:
return std::find(keywords, keywords + 20, s ) != keywords + 20;