In C++ why can't I write a for() loop like this: for( int i = 1, double i2 = 0;

后端 未结 7 1913
名媛妹妹
名媛妹妹 2020-12-03 20:49

or, \"Declaring multiple variables in a for loop ist verboten\" ?!

My original code was

 for( int i = 1, int i2 = 1; 
      i2 < mid;
      i++, i         


        
7条回答
  •  暖寄归人
    2020-12-03 21:35

    I can see why you hope that would work, but---given that even using the rather simple minded teaching tool that

    for (i=0; i

    is equivalent to

    i=0;
    while (i

    you syntax doesn't work---I can't see why you expected that it would. EAch of the bits need to be valid.

提交回复
热议问题