Thread: Pointers
View Single Post
Old 03-02-2003, 11:29 AM   #11 (permalink)
arkadius
Registered User
 
Join Date: Mar 2003
Posts: 3
arkadius is on a distinguished road
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.
arkadius is offline   Reply With Quote