Question.2
A developer implements a deep copy:
class Buffer {
int* ptr; int size;
public:
Buffer(int n) : size(n), ptr(new int[n]) {}
Buffer(const Buffer& o) : size(o.size), ptr(new int[o.size]) {
std::memcpy(ptr, o.ptr, size * sizeof(int));
}
~Buffer() { delete[] ptr; }
};
Buffer a(4);
a.ptr[0] = 99;
Buffer b = a;
b.ptr[0] = 42;
printf("%d", a.ptr[0]);What is the output? (Assuming public access.)