The main reason for asking if A is ok, is that I'mnot 100% if A is standard accepted practice by all C++ compilers, and will notcause trouble with some compilers.
A is allowed according to the c++03 standard, so everycompiler should support this.
A name introduced by a declaration in a condition(either introduced by the type-specifier-seq or the declarator of the condition) is in scope from itspoint of declaration until the end of the substatements controlled by the condition. If the name is re-declared in theoutermost block of a substatement controlled by the condition, the declaration that re-declares thename is ill-formed. [Example: if (int x = f()) { int x; // ill-formed, redeclaration of x } else { int x; // ill-formed, redeclaration of x } —end example]
The value of a condition that is an initializeddeclaration in a statement other than a switch statement is the value of the declared variable implicitlyconverted to type bool. If that conversion is ill-formed, the program is ill-formed. The value of a condition thatis an initialized declaration in a switch statement is the value of the declared variable if it hasintegral or enumeration type, or of that variable implicitly converted to integral or enumeration type otherwise. The valueof a condition that is an expression is the value of the expression, implicitly converted to bool forstatements other than switch; if that conversion is ill-formed, the program is ill-formed. The value ofthe condition will be referred to as simply “the condition” where the usage is unambiguous.
But keep in mind that you may not use any additionalparentheses or logical operators.
Regards, Markus