bool hasWord(int y, int x, string &word) {
if(!inRange(y, x)) return false;
if(board[y][x] != word[0]) return false;
if(word.size() == 1) return true;
for(int direction = 0; direction < 8; direction++) {
int nextX = x + dx[direction];
int nextY = y + dy[direction];
if(hasWord(nextY, nextX, word.substr(1))) // <--- This
return true;
}
return false; }
error: invalid initialization of non-const reference of type ‘std::string& {aka std::basic_string&}’ from an rvalue of type ‘std::basic_string’ if(hasWord(nextY, nextX, word.substr(1)))
why the reason I was wrong?