In what order does evaluation of post-increment operator happen?

后端 未结 4 1494
萌比男神i
萌比男神i 2021-01-20 08:36

Given

std::vector objects;
CMyClass list[MAX_OBJECT_COUNT];

Is it wise to do this?

for(unsigned int i = 0;          


        
4条回答
  •  被撕碎了的回忆
    2021-01-20 08:52

    When in doubt, prefer the form which is easier to understand (expand the loop).

    (And I think list[i] = objects.at(i++) leads to undefined behavior.)

提交回复
热议问题