I read an article by Straustrap, where I discussed the problem of integrating C and C ++. As we see, it seems that the problem has not been resolved. Even operator definitions differ mostly. In C, the control expression of an if expression can be equal to the expression. So, for example, this statement
if ( const char *p = std::strchr( "Hello", 'H' ) ) { }
valid in C ++ but similar operator
if ( char *p = strchr( "Hello", 'H' ) ) { }
not considered in C.
But in any case, your if statement was not specified in C ++, not in C. :)
if( (int a = 10) == 10 )
It can be either an expression or an ad. From the C ++ standard
condition: expression attribute-specifier-seqopt decl-specifier-seq declarator = initializer-clause attribute-specifier-seqopt decl-specifier-seq declarator braced-init-list
source share