Consider the following code in C++: Here *Lp will be a deep copy of L, containing a

Question:

Consider the following code in C++:

template  class cloneable_list : public list { public: cloneable_list* clone () { auto rtn = new cloneable_list(); for (auto e : *this) { rtn->push_back (e); return rtn; }; cloneable_list L; cloneable_list* Lp = L.clone (); %3D

Here *Lp will be a “deep copy” of L, containing a copy of each foo object. Try to write equivalent code in Java. What goes wrong? How might you get around the problem?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: