Code Room
Code reviewHardcr-g154
Subject Double freeLevel Senior–Staff~30 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this C++ RAII buffer wrapper.

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
class Buffer {public:    explicit Buffer(size_t n) : data_(new char[n]), size_(n) {}    ~Buffer() { delete[] data_; }    char* get() { return data_; }private:    char* data_;    size_t size_;}; void consume(Buffer b);   // takes by value void run() {    Buffer buf(4096);    consume(buf);            // pass a copy    buf.get()[0] = 'x';}
Run or narrate your approach, then ask the coach.