Code Room
Code reviewMediumcr-g164
Subject Iterator invalidationLevel Mid–Senior~25 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this C++ range-for that duplicates flagged items.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.

Talk through your review
Code to reviewcpp
#include <vector> struct Item { int id; bool flagged; }; void expand(std::vector<Item>& items) {    for (const Item& it : items) {        if (it.flagged) {            items.push_back(Item{ it.id + 1000, false });        }    }}
Run or narrate your approach, then ask the coach.