这是我的代码:
while( Func(x) != ERR_D)
{
if(result == ERR_A)
throw...;
if(result == ERR_B)
throw...;
mydata.x = x;
}
Run Code Online (Sandbox Code Playgroud)
问题是我想result = Func(x)在while条件中使用,因为结果将在while循环中检查.while循环应该调用Func(x)直到它返回ERR_D.我不能用
do{
result = Func(x);
if(result == ERR_A)
throw ...;
if(result == ERR_B)
throw ...;
mydata.x = x;
}while(result != ERR_D);
Run Code Online (Sandbox Code Playgroud)
在我的项目中,因为它第一次调用Func(x),这是我不想要的.但我试过while(result = Func(x) != ERR_D),它不起作用.任何解决这个问题的想法?