我目前正在为我的一门课制作一个双向链接列表。我们的压力测试之一如下所示:
//Delcarations
DLList<string> list;
DLList<string>* list2;
list.clear(); //Clears the list
list2 = &list; //Sets the values to be the same
list.addHead("I'm meant to be here"); //Adds this as head of both lists
*list2 = list; //Unsure what this does
printFunc(*list2); //prints the contents of the list
我的输出框只显示list
和list2
都变成NULL
,当我打印*list2
时它打印NULL
。
我的问题是:
*list2 = list
实际在做什么?*list2 = list
正在更改数据的值
您的两条评论不正确。也许更正的评论会使情况更加清晰?