Hey there, I can't seem to figure out why i can't access the member '*next' from the Node class in the Shuffle function. Any help would be great. Thanks.
#include <iostream>
#include "llist.h"
int main (int argc, char * const argv[]) {
LList *myTestList = new LList;
cout << "will test insertion..." << endl;
myTestList->InsertFirst("abanico");
myTestList->InsertFirst("berro");
myTestList->InsertFirst("caballo");
myTestList->InsertFirst("dado");
cout << myTestList << endl;
cout << "will test delete..." << endl;
myTestList->DeleteFirst();
cout << "List after deleting the first element..." << endl;
cout << myTestList << endl;
cout << "Finding berro" << endl;
cout << myTestList->FindFirst("berro") << endl;
cout << "Finding dado" << endl;
cout << myTestList->FindFirst("dado") << endl;
//myTestList->DeleteAll();
LList myTestList2;
myTestList2 = *myTestList;
cout << "This is the content of TestList2\n" << myTestList2 << endl;
delete(myTestList);
cout << "This is the content of TestList2 after delete of TestList1:\n" << myTestList2 << endl;
/*----------------------------------------------------------------------------------------------------------*/
cout << "\nAdd an external friend function called 'Shuffle' that " << endl;
cout << "takes as input two existing lists" << endl;
cout << "(the ones using linked lists)and creates (and returns) " << endl;
cout << "a shuffled list of the elements in the two lists." << endl;
LList *newlist1 = new LList;
LList *newlist2 = new LList;
LList *newlist3 = new LList;
newlist1->InsertFirst("10");
newlist1->InsertFirst("20");
//newlist1->InsertFirst("30");
//newlist1->InsertFirst("40");
newlist2->InsertFirst("8");
newlist2->InsertFirst("16");
//newlist2->InsertFirst("24");
//newlist2->InsertFirst("32");
LList list1;
LList list2;
LList list3;
list1 = *newlist1;
cout << "\nThis is the content of List 1:\n" << list1 << endl;
list2 = *newlist2;
cout << "\nThis is the content of List 2:\n" << list2 << endl;
//list3 = *newlist3;
cout << "\nThis is the content of List 3:\n" << endl;
newlist3 = Shuffle(list1, list2);
//cout << list3 << endl;
/*------------------------------------------------------------------------------------------------------------*/
int dummy;
cout << "\nCreating a big list so that we can see impact in memory..\n";
cin >> dummy;
for (int i=0; i<10000; i++) {
myTestList2.InsertFirst("porqueria");
}
cin >> dummy;
delete(&myTestList2);
cin >> dummy;
LList *myTestList3 = new LList;
cout << "Creating a big list so that we can see impact in memory..\n";
cin >> dummy;
for (int i=0; i<10000; i++) {
myTestList3->InsertFirst("porqueria");
}
cin >> dummy;
delete(myTestList3);
cin >> dummy;
return 0;
}
I'm not willing to compile your code myself. Explain in greater detail what is supposed to happen and what actually happens. You should only post the relevant parts of code. Also, try to debug yourself. That is an incredibly useful skill..