P
pauldepstein
I recently had a job interview question which I totally failed. (The
question seemed excellent from an objective point of view, but having
completely failed to do it, my subjective feelings are different.)
It's hard for me to recall the question exactly. But basically, it
involved a class construction with a shallow copy constructor.
The question was basically "What is the bug in this code?" The
intended answer was that shallow copies would lead to an attempt to
destruct the same object twice, and that a deep copy constructor was
needed. The intended answer involved rewriting the shallow copy
constructor.
Because I think technical interviews should be a learning experience, I
tried to find out about these concepts through googling. However, when
I researched copy constructors, I mainly found shallow copy
constructors that the examiner said were inappropriate for the example.
Can anyone show me where to get guidance on these concepts? Can anyone
think of an example where shallow copies interfere with the destructor,
and where deep copies are therefore needed.
I'm sorry that I can't recall the question more accurately but I hope
I've said enough for people to offer words of wisdom (perhaps by
recommending other websites.)
Thanks a lot for your help.
Paul Epstein
question seemed excellent from an objective point of view, but having
completely failed to do it, my subjective feelings are different.)
It's hard for me to recall the question exactly. But basically, it
involved a class construction with a shallow copy constructor.
The question was basically "What is the bug in this code?" The
intended answer was that shallow copies would lead to an attempt to
destruct the same object twice, and that a deep copy constructor was
needed. The intended answer involved rewriting the shallow copy
constructor.
Because I think technical interviews should be a learning experience, I
tried to find out about these concepts through googling. However, when
I researched copy constructors, I mainly found shallow copy
constructors that the examiner said were inappropriate for the example.
Can anyone show me where to get guidance on these concepts? Can anyone
think of an example where shallow copies interfere with the destructor,
and where deep copies are therefore needed.
I'm sorry that I can't recall the question more accurately but I hope
I've said enough for people to offer words of wisdom (perhaps by
recommending other websites.)
Thanks a lot for your help.
Paul Epstein