Code Room
Code reviewMedium
Question
Review this C++ code that stores pointers to loop-local objects.
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.
Learn the concepts
#include <vector>#include <string> std::vector<const std::string*> collect(const std::vector<int>& ids) { std::vector<const std::string*> out; for (int id : ids) { std::string label = "id-" + std::to_string(id); out.push_back(&label); } return out;}Run or narrate your approach, then ask the coach.