|
Hello,
Since we're on linked lists, maybe someone can help me with this:
linked list copy constructor and a destructor
basically the class is as follows
class SortedList
{
private:
struct Node
{
SomeItem data;
Node *next;
}
Node *head;
int size;
public:
// retrieve, insert, remove whatnot
};
//
SortedList::SortedList(SortedList &SL)
{
//ok, here's what I'm thinking
head = SL.head;
size = SL.size;
Node *pCur;
pCur = new Node;
pCur = SL.head->next; // did I just lose the node here?
head->next = pCur;
// assuming the first part is right how do I get the
// next nodes from SL? when do I make a heap for them?
}
Any help would be appreciated.
|