A junior hired because he's your team lead's cousin wrote the Buffer class, approved his own code review and left for a no-signal vacation. On Friday night prod started crashing on every buffer copy, and your team lead 'believes in you'. The double free believes in no one. Fix the class — the vacation has two more weeks to go.
You have a Buffer class that wraps a heap-allocated array. Your colleague wrote it but it has critical bugs — using it crashes or corrupts memory. Implement the full class following the Rule of Three.
The compiler-generated copy constructor copies the pointer, not the data — so two buffers share one allocation.
In the copy constructor and copy assignment, allocate a NEW array and memcpy the bytes into it.
Guard operator= against self-assignment (if (this == &other) return *this;) before deleting your old buffer.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.