};
void list::Copy (list& l) { node* p = new node(l.first->val);
first = p;
for (node*q=p->next; p; p=p->next)
Last()->Add(q->val);
}
this is the hard part for me.. i'm learning alone, only help is you and the books. i understand the notion of pointers and references, but i'm still kinda newbie in using them so deep,, so this just messes me up. can someone enlighten me mot-a-mot if possible ? Thank you.
this came afterwards..
first = pointer to objects of class node*
l.first = member first of object pointed by l ?
l.first->val = member val of object pointed by member first of object l ?
don't really make any sense
Create a variable p, of the type "pointer to a node-struct" and create a new node-object, setting it's value to.
In other words, p now contains the memory address of a new Node.
first = p;
Set the member variable "first" of the List-object to the same memory address as the one in p.
This is done so that you will always have the latest inserted element of the list as the "first" element accessible.
for (node*q=p->next; p; p=p->next)
While there are more values in the list that is being copied: