Unformatted text preview: d just have a pointer to the actual items.
So if the head item were removed from list1,
list2 would still point at it.
list2 Thus, if we create two linked lists
LinkedList list1, list2;
then add some items to list1, and then
list2 = list1;
we get a copy of only the Head.
Applied Programming A dangling pointer.
dangling This is called deep copying.
deep W hen we pass an object by value to a function or
have an object being the return value for a
function, an implicit copy is also carried out.
function, W e provide another class function to C++ so that
it is called whenever a copy is to be made.
This form of implicit copying is required not just
when an assignment is made.
Let's leave the assignment operation for a
moment and look at the other time that such
copying is needed.
Applied Programming W e might prefer to copy all the data, making
copies of the nodes of the linked list.
Applied Programming The difference here...
View Full Document
- Spring '14
- Object-Oriented Programming, Subroutine, Programming constructs, TimeType