我有一个看起来像这样的函数:
int Game::GetInput() {
while (true) {
// do stuff
if (something) {
// do this
return 0;
}
else {
// do other stuff
}
}
}
我想知道为了离开函数的唯一目的而使用返回函数而不是 void 函数是否常见或适当(除了结束函数之外,返回的值在程序中不会做任何事情)。这是一种好的做法,还是有更好的方法来结束函数?