C++, variable declaration in 'if' expression
问题 What\'s going on here? if(int a = Func1()) { // Works. } if((int a = Func1())) { // Fails to compile. } if((int a = Func1()) && (int b = Func2())) ) { // Do stuff with a and b. // This is what I\'d really like to be able to do. } Section 6.4.3 in the 2003 standard expains how variables declared in a selection statement condition have scope that extends to the end of the substatements controlled by the condition. But I don\'t see where it says anything about not being able to put parenthesis