Hello again,
I have yet another issue that I can't seem to get around.
I have a class called node, which has two private fields: a data field, and a link field. These nodes form a linked list, with one node's link field pointing to the next node, and so on, until the final node's link which is NULL.
I am trying to change the order of the nodes...and to do so I have to change the link field of the node. I am having an issue changing the links in the node. I thought I had an understanding of exactly how to do it. Consider this:
head_ptr points to the first node. The link of the first node points to the second node. I want to change head_ptr to "skip" over the second node and make it point to the third node. A pointer called marker_ptr points to the third node. Essentially, I want to make the link field (which is a pointer) that head_ptr points to, point to the node that marker_ptr points to. I have backup pointers to each of these first three nodes so that they do not become "unlinked" from the list. Here is my line of code that I thought should perform this task:
Note: the node class definition is in a header file. This code is in my implementation file.
|
head_ptr->node::link() = marker_ptr;
|
Correct me if I'm wrong, but the above code means: Change the link of the node that head_ptr points to to what marker_ptr points to.
Upon compiling I get this error:
error: lvalue required as left operand of assignment |
This error points to that line of code I have written above.
I feel like I'm missing an operator, but I'm kind of confused as to what the de-referencing and address operators will actually do in this case. Thanks for your help, this forum has been super helpful thus far.