how do you make a node of pointer of a device? (device is just a class that i made up, i need to use pointers in LL so i can "share" one object with multiple LLs)
struct node
{
device * devicePtr;
node * left, * right, * next;
node(const device * dvptr) {
dvptr = NULL;
left = right = next = NULL; }
}
then how can i access to the pointer? such as when i do a copy constructor
const list& list::operator= (const list& aList)
{
//if self copy, don't do anything
if(this == &aList)
return *this;
//release exist memory , if there's any
if (head)
{
destroyList();
}
//make *this a deep copy of "aList"
if(!aList.head)
head = NULL;
else
{
//copy the first node
head = new node(aList.head->dvptr);
node * currSrc = aList.head->dvptr;
node * currDes = head;
while(currSrc)
{
currDes->next = new node(currSrc->dvptr);
currDes = currDes->next;
currSrc = currSrc->next;
}
currDes->next = NULL;
}
return *this;
}
I know that aList.head->dvptr
and currSrc->dvptr
are wrong but i don't know how else
Can anyone point it out for me?
Thanks