How do I put two increment statements in a C++ 'for' loop?

前端 未结 8 764
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 02:55

I would like to increment two variables in a for-loop condition instead of one.

So something like:

for (int i = 0; i != 5; ++i and ++j)          


        
8条回答
  •  日久生厌
    2020-11-28 03:42

    Try not to do it!

    From http://www.research.att.com/~bs/JSF-AV-rules.pdf:

    AV Rule 199
    The increment expression in a for loop will perform no action other than to change a single loop parameter to the next value for the loop.

    Rationale: Readability.

提交回复
热议问题