119. Copy Semantics-I

Question.1

A class manages a heap buffer with no custom copy logic:

class Buffer {
   int* ptr;
public:
   Buffer(int n) : ptr(new int[n]) {}
   ~Buffer() { delete[] ptr; }
};

Buffer a(64);
Buffer b = a;  // Default shallow copy

What happens when both a and b go out of scope?

Need Help? Refer to the Quick Guide below

Select Answer