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; }
Run Code Online (Sandbox Code Playgroud)
错误:从类型为 'std::basic_string' 的右值对类型为 'std::string& {aka std::basic_string&}' 的非常量引用进行无效初始化 if(hasWord(nextY, nextX, word.substr(1)) )
为什么我错了?
function openFileDialog() {
dialog.showOpenDialog(win, {
properties: ['openFile']
} , filepath => {
if (filepath) {
fs.writeFile('path.txt', filepath, function (err, data) {
if (err) console.log(err);
});
scanFile(filepath)
}
})
}
function scanFile(filepath) {
if(!filepath || filepath[0] == 'undefined') return;
console.log(filepath)
fs.readFile(filepath,"utf8", (err,data) => { // ----> *ERROR*
if(err) console.log(err);
var arr = [];
if (data.substr(-4) === '.mp3' || data.substr(-4) === '.m4a'
|| data.substr(-5) === '.webm' || data.substr(-4) === '.wav'
|| data.substr(-4) === '.aac' || data.substr(-4) === '.ogg'
|| data.substr(-5) === '.opus') …Run Code Online (Sandbox Code Playgroud)