I have a header which allows the class to take another class of the same type as a parameter. Calling the functions of the parameratized object works just fine but I can't seem to create Node structs even within the object. I want to compare two lists by iterating through both of them and without the ability to reference objects created within the parametrized object, I have no idea how I would do the comparison. How can I create a Node struct within the parameratized object?
How can I create a Node struct within the parameratized object?
This kind of contradicts. Either you want to compare or modify.
For findIntersections(...) you should create a third List which is filled with the intersections (simply using InsertNode(...). if iteratorList is supposed to be the result as well you can assign the third list to it at the end.
How can I compare them if I can't create nodes based on the referenced &iteratorList? I also don't know how a third object would help. I should have posted my intentions here, I realize.
I want to iterate through iteratorList and see if there is a match in the object we are in, compareList. If there is, print it. I don't want you to write the code for me but I don't know how to iterate through iteratorLiat without creating a Node stuct within it.
def print_common(aList, bList):
for b in bList:
if is_member(b, aList): //if there is a match
print(b)
def is_member(node, list):
for x in list:
if x.data == node.data
returntruereturnfalse
¿is that what you want to do?
> Calling the functions of the parameratized object works just fine
> but I can't seem to create Node structs even within the object.
I don't understand the second part. int findIntersections( List &iteratorList )
you have two lists there `iteratorList' (terrible name) and `*this',
you may traverse them starting from `iteratorList.head' and `this->head'
¿why do you need to create another Node?