C++ 如何避开while循环?c++; void fireShip1(int Numbers2[],bool notFound,int position1,字符串播放器,int numberOfSunkenShips,int numberOfShips) { numberOfSunkenShips=0; while(notFound=true) { 库特

C++ 如何避开while循环?c++; void fireShip1(int Numbers2[],bool notFound,int position1,字符串播放器,int numberOfSunkenShips,int numberOfShips) { numberOfSunkenShips=0; while(notFound=true) { 库特,c++,C++,应该是: while (notFound = true) 或者简单地说: //assume you have declared notFound while (notFound == true) //^^^ 您是否在循环上方声明notFound,并将其设置为初始值true?@Lakey Its声明为函数的参数。@JohnnyMopp:或者更好:while(notFound)使用while(true),然后使用break?或者,while(numberOfSunke

应该是:

while (notFound = true)
或者简单地说:

//assume you have declared notFound
while (notFound == true)
              //^^^

您是否在循环上方声明notFound,并将其设置为初始值true?@Lakey Its声明为函数的参数。@JohnnyMopp:或者更好:
while(notFound)
使用
while(true)
,然后使用
break
?或者,
while(numberOfSunkenShips
notFound值不会影响问题。numberOfSunkenShips++;似乎不起作用,因为我正在使用return。删除return允许numberOfSunkenShips++起作用,但我需要使用return才能使程序的另一部分起作用
//assume you have declared notFound
while (notFound == true)
              //^^^
while (notFound)